From 95c6258d0f27ca0f0e5f9a787406376b62e42794 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 9 Apr 2018 15:10:23 +0200 Subject: [PATCH 1/2] Handle plugin not found due to mixed plugin metadata CURA-5202 Plugin metadata that comes from the plugin server is also saved into PluginRegistry's metadata collection, so it's all mixed. Plugins that are just installed cannot be loaded immediately, and this causes an error in checkCanUpgrade(). --- plugins/PluginBrowser/PluginBrowser.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/PluginBrowser/PluginBrowser.py b/plugins/PluginBrowser/PluginBrowser.py index 518528f776..f85c2cb85f 100644 --- a/plugins/PluginBrowser/PluginBrowser.py +++ b/plugins/PluginBrowser/PluginBrowser.py @@ -6,6 +6,7 @@ from PyQt5.QtNetwork import QNetworkAccessManager, QNetworkRequest, QNetworkRepl from UM.Application import Application from UM.Logger import Logger +from UM.PluginError import PluginNotFoundError from UM.PluginRegistry import PluginRegistry from UM.Qt.Bindings.PluginsModel import PluginsModel from UM.Extension import Extension @@ -302,10 +303,15 @@ class PluginBrowser(QObject, Extension): return self._plugins_model def _checkCanUpgrade(self, plugin_id, version): - if plugin_id not in self._plugin_registry.getInstalledPlugins(): + if not self._plugin_registry.isInstalledPlugin(plugin_id): + return False + + try: + plugin_object = self._plugin_registry.getPluginObject(plugin_id) + except PluginNotFoundError: + Logger.log("w", "Could not find plugin %s", plugin_id) return False - plugin_object = self._plugin_registry.getPluginObject(plugin_id) # Scan plugin server data for plugin with the given id: for plugin in self._plugins_metadata: if plugin_id == plugin["id"]: From 95f4515e93144e5a1c23f9773a2d58b69fcdd0ab Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Tue, 10 Apr 2018 11:40:22 +0200 Subject: [PATCH 2/2] Make it possible to skip project file check in readLocalFile() CURA-5203 --- cura/CuraApplication.py | 6 +++--- resources/qml/AskOpenAsProjectOrModelsDialog.qml | 2 +- resources/qml/Menus/RecentFilesMenu.qml | 2 +- resources/qml/OpenFilesIncludingProjectsDialog.qml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 205f918ec4..6e07e35ad9 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -1557,8 +1557,8 @@ class CuraApplication(QtApplication): openProjectFile = pyqtSignal(QUrl, arguments = ["project_file"]) # Emitted when a project file is about to open. - @pyqtSlot(QUrl) - def readLocalFile(self, file): + @pyqtSlot(QUrl, bool) + def readLocalFile(self, file, skip_project_file_check = False): if not file.isValid(): return @@ -1569,7 +1569,7 @@ class CuraApplication(QtApplication): self.deleteAll() break - if self.checkIsValidProjectFile(file): + if not skip_project_file_check and self.checkIsValidProjectFile(file): self.callLater(self.openProjectFile.emit, file) return diff --git a/resources/qml/AskOpenAsProjectOrModelsDialog.qml b/resources/qml/AskOpenAsProjectOrModelsDialog.qml index bd37d1acdb..6b1856723b 100644 --- a/resources/qml/AskOpenAsProjectOrModelsDialog.qml +++ b/resources/qml/AskOpenAsProjectOrModelsDialog.qml @@ -53,7 +53,7 @@ UM.Dialog UM.Preferences.setValue("cura/choice_on_open_project", "open_as_model") } - CuraApplication.readLocalFile(base.fileUrl) + CuraApplication.readLocalFile(base.fileUrl, true) var meshName = backgroundItem.getMeshName(base.fileUrl.toString()) backgroundItem.hasMesh(decodeURIComponent(meshName)) diff --git a/resources/qml/Menus/RecentFilesMenu.qml b/resources/qml/Menus/RecentFilesMenu.qml index 579eb24344..12f53fb517 100644 --- a/resources/qml/Menus/RecentFilesMenu.qml +++ b/resources/qml/Menus/RecentFilesMenu.qml @@ -61,7 +61,7 @@ Menu } else if (toOpenAsModel) { - CuraApplication.readLocalFile(modelData); + CuraApplication.readLocalFile(modelData, true); } var meshName = backgroundItem.getMeshName(modelData.toString()) backgroundItem.hasMesh(decodeURIComponent(meshName)) diff --git a/resources/qml/OpenFilesIncludingProjectsDialog.qml b/resources/qml/OpenFilesIncludingProjectsDialog.qml index af8fb9e05f..3dcd4b6236 100644 --- a/resources/qml/OpenFilesIncludingProjectsDialog.qml +++ b/resources/qml/OpenFilesIncludingProjectsDialog.qml @@ -42,7 +42,7 @@ UM.Dialog { for (var i in fileUrls) { - CuraApplication.readLocalFile(fileUrls[i]); + CuraApplication.readLocalFile(fileUrls[i], true); } var meshName = backgroundItem.getMeshName(fileUrls[0].toString());