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 28
28
29
29
"""
30
30
31
- from qgis .PyQt .QtCore import QCoreApplication , QLocale , QThread
31
+ from qgis .PyQt .QtCore import QCoreApplication , QLocale , QThread , qDebug
32
32
from qgis .PyQt .QtWidgets import QPushButton , QApplication
33
33
from qgis .core import Qgis , QgsMessageLog , qgsfunction , QgsMessageOutput
34
34
from qgis .gui import QgsMessageBar
@@ -411,12 +411,23 @@ def _unloadPluginModules(packageName):
411
411
if hasattr (sys .modules [mod ], 'qCleanupResources' ):
412
412
sys .modules [mod ].qCleanupResources ()
413
413
except :
414
- pass
414
+ # Print stack trace for debug
415
+ qDebug ("qCleanupResources error:\n %s" % traceback .format_exc ())
416
+
417
+ # try removing path
418
+ if hasattr (sys .modules [mod ], '__path__' ):
419
+ for path in sys .modules [mod ].__path__ :
420
+ try :
421
+ sys .path .remove (path )
422
+ except ValueError :
423
+ # Discard if path is not there
424
+ pass
425
+
415
426
# try to remove the module from python
416
427
try :
417
428
del sys .modules [mod ]
418
429
except :
419
- pass
430
+ qDebug ( "Error when removing module: \n %s" % traceback . format_exc ())
420
431
# remove the plugin entry
421
432
del _plugin_modules [packageName ]
422
433
You can’t perform that action at this time.
0 commit comments