Skip to content

Commit

Permalink
Fix reloading plugin submodules.
Browse files Browse the repository at this point in the history
  • Loading branch information
borysiasty committed Oct 13, 2018
1 parent 4025d80 commit 64ccae0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
0.7.5
Fix reloading plugin submodules.

0.7.4
Set the keyboard shortcut to Ctrl+F5 by default and make it properly configurable

Expand Down
2 changes: 1 addition & 1 deletion metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ name=Plugin Reloader
qgisMinimumVersion=3.0
description=Reloads a chosen plugin in one click
about=This tool is only useful for Python Plugin Developers!
version=0.7.4
version=0.7.5

# Optional items:

Expand Down
9 changes: 9 additions & 0 deletions reloader_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# ***************************************************************************

import os
import sys
from qgis.PyQt.QtCore import *
from qgis.PyQt.QtGui import *
from qgis.PyQt.QtWidgets import *
Expand Down Expand Up @@ -157,6 +158,14 @@ def run(self):
plugin = currentPlugin()
if plugin in plugins:
state = self.iface.mainWindow().saveState()

# Unload submodules
for key in [key for key in sys.modules.keys()]:
if '%s.' % plugin in key:
if hasattr(sys.modules[key], 'qCleanupResources'):
sys.modules[key].qCleanupResources()
del sys.modules[key]

reloadPlugin(plugin)
self.iface.mainWindow().restoreState(state)
self.iface.messageBar().pushMessage("<b>%s</b> reloaded." % plugin, QGis.Info)
Expand Down

0 comments on commit 64ccae0

Please sign in to comment.