on master help sign in
Make the "shutdown" method of Vty idempotent (fixes #159)
commit5050413a2b70388be805b40bf1e4f070bb5c4ff8 authorJonathan Daugherty <cygnus@foobox.com> dateSun 14 Oct 2018, 20:00 (8 years ago) parent53c02c6
1 file changed+10−3
src/Graphics/Vty.hs+10−3
src/Graphics/Vty.hs+10−3
@@ -52,6 +52,7 @@ import Graphics.Vty.Picture
5252import Graphics.Vty.Image
5353import Graphics.Vty.Attributes
5454
55+import Control.Monad (when)
5556import Control.Concurrent.STM
5657
5758import Data.IORef
@@ -115,10 +116,16 @@ mkVty appConfig = do
115116intMkVty :: Input -> Output -> IO Vty
116117intMkVty input out = do
117118 reserveDisplay out
119+
120+ shutdownVar <- atomically $ newTVar False
118121 let shutdownIo = do
119− shutdownInput input
120− releaseDisplay out
121− releaseTerminal out
122+ alreadyShutdown <- atomically $ readTVar shutdownVar
123+ when (not alreadyShutdown) $ do
124+ atomically $ writeTVar shutdownVar True
125+ shutdownInput input
126+ releaseDisplay out
127+ releaseTerminal out
128+
122129 lastPicRef <- newIORef Nothing
123130 lastUpdateRef <- newIORef Nothing
124131