Skip to content

Commit

Permalink
Merge pull request #17 from guibou/remove-add-cleanup
Browse files Browse the repository at this point in the history
Remove usage of addCleanup
  • Loading branch information
albertov authored Mar 29, 2021
2 parents 1bc49ec + d028778 commit 9ed088e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/GDAL/Internal/Layer.chs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ module GDAL.Internal.Layer (
import Data.ByteString.Unsafe (unsafeUseAsCString)
import Data.Coerce (coerce)
import Data.Conduit ( Conduit, Sink, Source
, addCleanup, awaitForever, yield
, awaitForever, yield
, bracketP, catchC
, (=$=))
import qualified Data.Conduit.List as CL
Expand Down Expand Up @@ -377,9 +377,12 @@ instance HasLayerTransaction ReadWrite where
bracketP (alloc' state) free $ \ seed@(layer,_) -> do
liftIO $ checkOGRError "StartTransaction" $
{#call OGR_L_StartTransaction as ^#} (unLayer layer)
addCleanup (\terminated -> when terminated (commit layer)) $

res <-
inside seed `catchC`
\(e :: SomeException) -> rollback layer >> throwM e
commit layer
pure res
where
alloc' = runWithInternalState alloc
free = closeLayer . fst
Expand Down

0 comments on commit 9ed088e

Please sign in to comment.