File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 2828
2929"""
3030
31- from qgis .PyQt .QtCore import QCoreApplication , QLocale , QThread
31+ from qgis .PyQt .QtCore import QCoreApplication , QLocale , QThread , qDebug
3232from qgis .PyQt .QtWidgets import QPushButton , QApplication
3333from qgis .core import Qgis , QgsMessageLog , qgsfunction , QgsMessageOutput
3434from qgis .gui import QgsMessageBar
@@ -452,12 +452,23 @@ def _unloadPluginModules(packageName):
452452 if hasattr (sys .modules [mod ], 'qCleanupResources' ):
453453 sys .modules [mod ].qCleanupResources ()
454454 except :
455- pass
455+ # Print stack trace for debug
456+ qDebug ("qCleanupResources error:\n %s" % traceback .format_exc ())
457+
458+ # try removing path
459+ if hasattr (sys .modules [mod ], '__path__' ):
460+ for path in sys .modules [mod ].__path__ :
461+ try :
462+ sys .path .remove (path )
463+ except ValueError :
464+ # Discard if path is not there
465+ pass
466+
456467 # try to remove the module from python
457468 try :
458469 del sys .modules [mod ]
459470 except :
460- pass
471+ qDebug ( "Error when removing module: \n %s" % traceback . format_exc ())
461472 # remove the plugin entry
462473 del _plugin_modules [packageName ]
463474
You can’t perform that action at this time.
0 commit comments