From 232713a0193b7f485340af440f56794ae2b222a2 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 1 Mar 2016 13:16:57 +0100 Subject: [PATCH] Catch file open events before file loaders are loaded The event is essentially delayed. The filename is put in a list by the event handler. The list of files is then loaded after all plug-ins are loaded. Contributes to issue CURA-730. --- cura/CuraApplication.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index f70c7fba6a..f0c7008b46 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -78,8 +78,13 @@ class CuraApplication(QtApplication): if not hasattr(sys, "frozen"): Resources.addSearchPath(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..")) + self._open_file_queue = [] #Files to open when plug-ins are loaded. + super().__init__(name = "cura", version = CuraVersion) + for file_name in self._open_file_queue: #Open all the files that were queued up while plug-ins were loading. + self._openFile(file_name) + self.setWindowIcon(QIcon(Resources.getPath(Resources.Images, "cura-icon.png"))) self.setRequiredPlugins([ @@ -148,6 +153,8 @@ class CuraApplication(QtApplication): if self.getBackend() == None: raise RuntimeError("Could not load the backend plugin!") + self._plugins_loaded = True + def addCommandLineOptions(self, parser): super().addCommandLineOptions(parser) parser.add_argument("file", nargs="*", help="Files to load after starting the application.") @@ -211,8 +218,10 @@ class CuraApplication(QtApplication): # Handle Qt events def event(self, event): if event.type() == QEvent.FileOpen: - Logger.log("i", "File open via Qt event: %s", event.file()) - self._openFile(event.file()) + if self._plugins_loaded: + self._openFile(event.file()) + else: + self._open_file_queue.append(event.file()) return super().event(event)