Skip to content

Instantly share code, notes, and snippets.

@timlinux
Created January 9, 2013 10:00
Show Gist options
  • Save timlinux/4492032 to your computer and use it in GitHub Desktop.
Save timlinux/4492032 to your computer and use it in GitHub Desktop.
def unload(self):
"""Gui breakdown procedure (for QGIS plugin api).
This method is called by QGIS and should be used to *remove*
any graphical user interface elements that should appear in QGIS.
Args:
None.
Returns:
None.
Raises:
no exceptions explicitly raised.
"""
# Remove the plugin menu item and icon
self.iface.removePluginMenu(self.tr('InaSAFE'),
self.actionDock)
self.iface.removeToolBarIcon(self.actionDock)
self.iface.removePluginMenu(self.tr('InaSAFE'),
self.actionKeywordsDialog)
self.iface.removeToolBarIcon(self.actionKeywordsDialog)
self.iface.removePluginMenu(self.tr('InaSAFE'),
self.actionResetDock)
self.iface.removeToolBarIcon(self.actionResetDock)
self.iface.removePluginMenu(self.tr('InaSAFE'),
self.actionOptions)
self.iface.removeToolBarIcon(self.actionOptions)
self.iface.removePluginMenu(self.tr('InaSAFE'),
self.actionImpactFunctionsDoc)
self.iface.removeToolBarIcon(self.actionImpactFunctionsDoc)
self.iface.mainWindow().removeDockWidget(self.dockWidget)
self.dockWidget.setVisible(False)
self.dockWidget.destroy()
QObject.disconnect(self.iface,
SIGNAL("currentLayerChanged(QgsMapLayer*)"),
self.layerChanged)
# Try to force unloading of all modules see issue #463
# https://github.com/AIFDR/inasafe/issues/463
for myKey in sys.modules.keys():
if 'safe' in myKey:
try:
del sys.modules[myKey]
except:
pass
try:
myLogger = logging.getLogger('InaSAFE')
myLogger.handlers = []
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment