haskell-gi-base 0.20.3 → 0.20.4
raw patch · 5 files changed
+25/−24 lines, 5 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.GI.Base.BasicTypes: instance ((TypeError ...), Data.GI.Base.BasicTypes.ManagedPtrNewtype a) => Data.GI.Base.BasicTypes.GObject a
- Data.GI.Base.ManagedPtr: newObject :: (GObject a, GObject b) => (ManagedPtr a -> a) -> Ptr b -> IO a
+ Data.GI.Base.ManagedPtr: newObject :: (HasCallStack, GObject a, GObject b) => (ManagedPtr a -> a) -> Ptr b -> IO a
- Data.GI.Base.ManagedPtr: wrapObject :: forall a b. (GObject a, GObject b) => (ManagedPtr a -> a) -> Ptr b -> IO a
+ Data.GI.Base.ManagedPtr: wrapObject :: forall a b. (HasCallStack, GObject a, GObject b) => (ManagedPtr a -> a) -> Ptr b -> IO a
Files
- ChangeLog.md +4/−0
- Data/GI/Base/BasicTypes.hs +0/−19
- Data/GI/Base/ManagedPtr.hs +18/−2
- Data/GI/Base/Signals.hsc +2/−2
- haskell-gi-base.cabal +1/−1
ChangeLog.md view
@@ -1,3 +1,7 @@+### 0.20.4+++ Better error diagnostics for [wrapObject](https://hackage.haskell.org/package/haskell-gi-base/docs/Data-GI-Base-ManagedPtr.html#v:wrapObject) and [newObject](https://hackage.haskell.org/package/haskell-gi-base/docs/Data-GI-Base-ManagedPtr.html#v:newObject).+ ### 0.20.3 + Fixes for GHC 8.2.1 (and the corresponding `base-4.10.0`).
Data/GI/Base/BasicTypes.hs view
@@ -55,10 +55,6 @@ import Foreign.Ptr (Ptr, FunPtr) import Foreign.ForeignPtr (ForeignPtr) -#if MIN_VERSION_base(4,9,0)-import GHC.TypeLits-#endif- import Data.GI.Base.CallStack (CallStack) import Data.GI.Base.GType @@ -112,21 +108,6 @@ class ManagedPtrNewtype a => GObject a where -- | The `GType` for this object. gobjectType :: a -> IO GType---- Raise a more understandable type error whenever the `GObject a`--- constraint is imposed on a type which has no such instance. This--- helps in the common case where one passes a wrong type (such as--- `Maybe Widget`) into a function with a `IsWidget a`--- constraint. Without this type error, the resulting type error is--- much less understandable, since GHC complains (at length) about a--- missing type family instance for `ParentTypes`.-#if MIN_VERSION_base(4,9,0)-instance {-# OVERLAPPABLE #-}- (TypeError ('Text "Type ‘" ':<>: 'ShowType a ':<>:- 'Text "’ does not descend from GObject."), ManagedPtrNewtype a)- => GObject a where- gobjectType = undefined-#endif -- | A common omission in the introspection data is missing (nullable) -- annotations for return types, when they clearly are nullable. (A
Data/GI/Base/ManagedPtr.hs view
@@ -218,19 +218,35 @@ foreign import ccall "g_object_ref_sink" g_object_ref_sink :: Ptr a -> IO (Ptr a) +-- | Print a warning when receiving a null pointer in a function that+-- did not expect one, for easier debugging.+nullPtrWarning :: String -> CallStack -> IO ()+nullPtrWarning fn cs =+ hPutStrLn stderr ("WARNING: Trying to wrap a null pointer in " ++ quotedFn+ ++ ", this may lead to crashes.\n\n"+ ++ "• Callstack for the unsafe call to "+ ++ quotedFn ++ ":\n"+ ++ prettyCallStack cs ++ "\n\n"+ ++ "This is probably a bug in the introspection data,\n"+ ++ "please report it at https://github.com/haskell-gi/haskell-gi/issues")+ where quotedFn = "‘" ++ fn ++ "’"+ -- | Construct a Haskell wrapper for a 'GObject', increasing its -- reference count, or taking ownership of the floating reference if -- there is one.-newObject :: (GObject a, GObject b) => (ManagedPtr a -> a) -> Ptr b -> IO a+newObject :: (HasCallStack, GObject a, GObject b) =>+ (ManagedPtr a -> a) -> Ptr b -> IO a newObject constructor ptr = do+ when (ptr == nullPtr) (nullPtrWarning "newObject" callStack) void $ g_object_ref_sink ptr fPtr <- newManagedPtr' ptr_to_g_object_unref $ castPtr ptr return $! constructor fPtr -- | Same as 'newObject', but we steal ownership of the object.-wrapObject :: forall a b. (GObject a, GObject b) =>+wrapObject :: forall a b. (HasCallStack, GObject a, GObject b) => (ManagedPtr a -> a) -> Ptr b -> IO a wrapObject constructor ptr = do+ when (ptr == nullPtr) (nullPtrWarning "wrapObject" callStack) fPtr <- newManagedPtr' ptr_to_g_object_unref $ castPtr ptr return $! constructor fPtr
Data/GI/Base/Signals.hsc view
@@ -102,7 +102,7 @@ -- | Same as `connectSignal`, specifying from the beginning that the -- handler is to be run before the default handler. ----- > on = connectSignal SignalConnectBefore+-- > on object signal handler = liftIO $ connectSignal signal object handler SignalConnectBefore on :: forall object info m. (GObject object, MonadIO m, SignalInfo info) => object -> SignalProxy object info@@ -111,7 +111,7 @@ -- | Connect a signal to a handler, running the handler after the default one. ----- > after = connectSignal SignalConnectAfter+-- > after object signal handler = liftIO $ connectSignal signal object handler SignalConnectAfter after :: forall object info m. (GObject object, MonadIO m, SignalInfo info) => object -> SignalProxy object info
haskell-gi-base.cabal view
@@ -1,5 +1,5 @@ name: haskell-gi-base-version: 0.20.3+version: 0.20.4 synopsis: Foundation for libraries generated by haskell-gi description: Foundation for libraries generated by haskell-gi homepage: https://github.com/haskell-gi/haskell-gi-base