@@ -818,6 +818,10 @@ subscribe e ws = do
818 liftIO $ subscribeEventSubscribed subd ws
818 liftIO $ subscribeEventSubscribed subd ws
819 return subd
819 return subd
821+noinlineFalse :: Bool
822+noinlineFalse = False
823+{-# NOINLINE noinlineFalse #-}
821getRootSubscribed :: Root a -> EventM (RootSubscribed a)
825getRootSubscribed :: Root a -> EventM (RootSubscribed a)
822getRootSubscribed r = do
826getRootSubscribed r = do
823 mSubscribed <- liftIO $ readIORef $ rootSubscribed r
827 mSubscribed <- liftIO $ readIORef $ rootSubscribed r
@@ -829,6 +833,7 @@ getRootSubscribed r = do
829 -- Strangely, init needs the same stuff as a RootSubscribed has, but it must not be the same as the one that everyone's subscribing to, or it'll leak memory
833 -- Strangely, init needs the same stuff as a RootSubscribed has, but it must not be the same as the one that everyone's subscribing to, or it'll leak memory
830 uninit <- rootInit r $ RootTrigger (subscribersRef, rootOccurrence r)
834 uninit <- rootInit r $ RootTrigger (subscribersRef, rootOccurrence r)
831 addFinalizer subscribed $ do
835 addFinalizer subscribed $ do
836+ when noinlineFalse $ putStr "" -- For some reason, without this line, the finalizer will run earlier than it should
832-- putStrLn "Uninit root"
837-- putStrLn "Uninit root"
834 liftIO $ writeIORef (rootSubscribed r) $ Just subscribed
839 liftIO $ writeIORef (rootSubscribed r) $ Just subscribed