diff --git a/GUI/App.hs b/GUI/App.hs index 9635685b..8cdb5007 100644 --- a/GUI/App.hs +++ b/GUI/App.hs @@ -28,7 +28,7 @@ initApp = do menuBar <- Gtk.menuBarNew OSX.applicationSetMenuBar app menuBar logo <- $loadLogo - OSX.applicationSetDockIconPixbuf app (Just logo) + OSX.applicationSetDockIconPixbuf app logo OSX.applicationReady app #else diff --git a/GUI/DataFiles.hs b/GUI/DataFiles.hs index 934b4fbd..fffb6072 100644 --- a/GUI/DataFiles.hs +++ b/GUI/DataFiles.hs @@ -1,13 +1,16 @@ +{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TemplateHaskell #-} module GUI.DataFiles ( ui , loadLogo ) where +import Control.Exception (IOException, Handler(..), catches) import System.IO import Data.FileEmbed import Graphics.UI.Gtk (Pixbuf, pixbufNewFromFile) import Language.Haskell.TH +import System.Glib (GError) import System.IO.Temp import qualified Data.ByteString as B import qualified Data.Text.Encoding as TE @@ -22,12 +25,17 @@ logoFile = "threadscope.png" ui :: Q Exp ui = [| TE.decodeUtf8 $(makeRelativeToProject uiFile >>= embedFile) |] -renderLogo :: B.ByteString -> IO Pixbuf +renderLogo :: B.ByteString -> IO (Maybe Pixbuf) renderLogo bytes = withSystemTempFile logoFile $ \path h -> do B.hPut h bytes hClose h - pixbufNewFromFile path + Just <$> pixbufNewFromFile path + `catches` + -- in case of a failure in the file IO or pixbufNewFromFile, return Nothing + [ Handler $ \(_ :: IOException) -> return Nothing + , Handler $ \(_ :: GError) -> return Nothing + ] -- | Load the logo file as a 'Pixbuf'. loadLogo :: Q Exp diff --git a/GUI/Dialogs.hs b/GUI/Dialogs.hs index 38be694f..395bc735 100644 --- a/GUI/Dialogs.hs +++ b/GUI/Dialogs.hs @@ -28,7 +28,7 @@ aboutDialog parent "Mikolaj Konarski ", "Nicolas Wu ", "Eric Kow "], - aboutDialogLogo := Just logo, + aboutDialogLogo := logo, aboutDialogWebsite := "http://www.haskell.org/haskellwiki/ThreadScope", windowTransientFor := toWindow parent ] diff --git a/GUI/MainWindow.hs b/GUI/MainWindow.hs index 77f1cf04..19122c38 100644 --- a/GUI/MainWindow.hs +++ b/GUI/MainWindow.hs @@ -141,7 +141,7 @@ mainWindowNew builder actions = do ------------------------------------------------------------------------ logo <- $loadLogo - set mainWindow [ windowIcon := Just logo ] + set mainWindow [ windowIcon := logo ] ------------------------------------------------------------------------ -- Status bar functionality