Skip to content
Permalink
Browse files

Merge pull request #2574 from SebDieBln/GDALtools_removeMenuItemsOnUn…

…load

Remove menu items when GDALtools plugin is unloaded (fixes #13642)
  • Loading branch information
jef-n committed Dec 12, 2015
2 parents f8c4b3a + dd2a422 commit 666eda68560c73ff72e2e1efb82a1d00a5eb48ff
Showing with 12 additions and 7 deletions.
  1. +12 −7 python/plugins/GdalTools/GdalTools.py
@@ -90,6 +90,9 @@ def __init__(self, iface):
self.translator.load(self.localePath)
QCoreApplication.installTranslator(self.translator)

# The list of actions added to menus, so we can remove them when unloading the plugin
self._menuActions = []

def initGui(self):
if not valid:
return
@@ -123,7 +126,7 @@ def initGui(self):
menu_bar.insertMenu(lastAction, self.menu)
else:
self.menu = rasterMenu
self.menu.addSeparator()
self._menuActions.append(self.menu.addSeparator())

# projections menu (Warp (Reproject), Assign projection)
self.projectionsMenu = QMenu(QCoreApplication.translate("GdalTools", "Projections"), self.iface.mainWindow())
@@ -280,25 +283,27 @@ def initGui(self):

self.miscellaneousMenu.addActions([self.merge, self.info, self.overview, self.tileindex])

self.menu.addMenu(self.projectionsMenu)
self.menu.addMenu(self.conversionMenu)
self.menu.addMenu(self.extractionMenu)
self._menuActions.append(self.menu.addMenu(self.projectionsMenu))
self._menuActions.append(self.menu.addMenu(self.conversionMenu))
self._menuActions.append(self.menu.addMenu(self.extractionMenu))

if not self.analysisMenu.isEmpty():
self.menu.addMenu(self.analysisMenu)
self._menuActions.append(self.menu.addMenu(self.analysisMenu))

self.menu.addMenu(self.miscellaneousMenu)
self._menuActions.append(self.menu.addMenu(self.miscellaneousMenu))

self.settings = QAction(QCoreApplication.translate("GdalTools", "GdalTools Settings..."), self.iface.mainWindow())
self.settings.setObjectName("settings")
self.settings.setStatusTip(QCoreApplication.translate("GdalTools", "Various settings for Gdal Tools"))
QObject.connect(self.settings, SIGNAL("triggered()"), self.doSettings)
self.menu.addAction(self.settings)
self._menuActions.append(self.settings)

def unload(self):
if not valid:
return
pass
for a in self._menuActions:
self.menu.removeAction(a)

def doBuildVRT(self):
from tools.doBuildVRT import GdalToolsDialog as BuildVRT

0 comments on commit 666eda6

Please sign in to comment.
You can’t perform that action at this time.