@@ -23,6 +23,7 @@ import Control.Monad.Ref
23import Control.Monad.Exception
23import Control.Monad.Exception
24import Data.Monoid ((<>))
24import Data.Monoid ((<>))
25import Data.Coerce
25import Data.Coerce
26+import Control.Exception
27import System.IO.Unsafe
28import System.IO.Unsafe
28import Unsafe.Coerce
29import Unsafe.Coerce
@@ -1107,12 +1108,12 @@ runFrame a = do
1107 finalize wsub
1108 finalize wsub
1108 wi <- readIORef $ switchSubscribedOwnWeakInvalidator subscribed
1109 wi <- readIORef $ switchSubscribedOwnWeakInvalidator subscribed
1109 finalize wi
1110 finalize wi
1110− let !i = switchSubscribedOwnInvalidator subscribed
1111+ i <- evaluate $ switchSubscribedOwnInvalidator subscribed
1111 wi' <- mkWeakPtrWithDebug i "wi'"
1112 wi' <- mkWeakPtrWithDebug i "wi'"
1112 writeIORef (switchSubscribedBehaviorParents subscribed) []
1113 writeIORef (switchSubscribedBehaviorParents subscribed) []
1113 e <- runBehaviorM (readBehaviorTracked (switchSubscribedParent subscribed)) (Just (wi', switchSubscribedBehaviorParents subscribed))
1114 e <- runBehaviorM (readBehaviorTracked (switchSubscribedParent subscribed)) (Just (wi', switchSubscribedBehaviorParents subscribed))
1114 --TODO: Make sure we touch the pieces of the SwitchSubscribed at the appropriate times
1115 --TODO: Make sure we touch the pieces of the SwitchSubscribed at the appropriate times
1115− let !sub = switchSubscribedSelf subscribed -- Must be done strictly, or the weak pointer will refer to a useless thunk
1116+ sub <- evaluate $ switchSubscribedSelf subscribed -- Must be done strictly, or the weak pointer will refer to a useless thunk
1116 wsub' <- mkWeakPtrWithDebug sub "wsub'"
1117 wsub' <- mkWeakPtrWithDebug sub "wsub'"
1117 writeIORef (switchSubscribedSelfWeak subscribed) wsub'
1118 writeIORef (switchSubscribedSelfWeak subscribed) wsub'
1118 subd' <- runFrame $ subscribe e $ WeakSubscriberSimple wsub' --TODO: Assert that the event isn't firing --TODO: This should not loop because none of the events should be firing, but still, it is inefficient
1119 subd' <- runFrame $ subscribe e $ WeakSubscriberSimple wsub' --TODO: Assert that the event isn't firing --TODO: This should not loop because none of the events should be firing, but still, it is inefficient