Commit 51f6c1b4 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

BF: Fix macOS desktop integration - MacOpenFiles gets called too early

parent 3cd63c37
......@@ -95,6 +95,14 @@ class FSLeyesApp(wx.App):
self.__overlayList = None
self.__displayCtx = None
# On macOS, when the user drags a file onto the FSLeyes window,
# or onto the icon, the file path will be passed to
# MacOpenFiles method. But that method may be called very early
# on in the startup process, before the DisplayContext and
# OverlayList have been created. So when this happens, we cache
# the files here, and then open them when the
# SetOverlayListAndDisplayContext method gets called.
self.__filesToOpen = []
self.__modalHook = FSLeyesApp.ModalHook()
......@@ -125,6 +133,14 @@ class FSLeyesApp(wx.App):
self.__overlayList = overlayList
self.__displayCtx = displayCtx
# MacOpenFiles was called before the
# overlaylist/dc were created, and
# queued some files that need to be
# opened
if len(self.__filesToOpen) > 0:
wx.CallAfter(self.MacOpenFiles, self.__filesToOpen)
self.__filesToOpen = None
def MacReopenApp(self):
"""On OSX, make sure that the FSLeyes frame is restored if it is
......@@ -169,7 +185,11 @@ class FSLeyesApp(wx.App):
on the application icon.
# OverlayList has not yet been created -
# queue the files to open them later
# in SetOverlayListAndDisplayContext
if self.__overlayList is None:
import fsleyes.actions.loadoverlay as loadoverlay
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment