From 1677b6cc056ff52cfd809e1f74719a6f1541a421 Mon Sep 17 00:00:00 2001 From: Sandro Mani Date: Thu, 25 May 2023 16:02:32 +0200 Subject: [PATCH] HACK: attempt to re-start a plugin if startup fails due to odd "The operation completed successfully" error --- python/utils.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/python/utils.py b/python/utils.py index f4890bf025201..04af12e576fdd 100644 --- a/python/utils.py +++ b/python/utils.py @@ -421,6 +421,17 @@ def _startPlugin(packageName: str) -> bool: # create an instance of the plugin try: plugins[packageName] = package.classFactory(iface) + except OSError as e: + if "The operation completed successfully" in str(e): + _unloadPluginModules(packageName) + try: + plugins[packageName] = package.classFactory(iface) + except: + _unloadPluginModules(packageName) + errMsg = QCoreApplication.translate("Python", "Couldn't load plugin '{0}'").format(packageName) + msg = QCoreApplication.translate("Python", "{0} due to an error when calling its classFactory() method").format(errMsg) + showException(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2], msg, messagebar=True, level=Qgis.Critical) + return False except: _unloadPluginModules(packageName) errMsg = QCoreApplication.translate("Python", "Couldn't load plugin '{0}'").format(packageName)