Skip to content

Commit

Permalink
Merge pull request #2574 from SebDieBln/GDALtools_removeMenuItemsOnUn…
Browse files Browse the repository at this point in the history
…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 666eda6
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions python/plugins/GdalTools/GdalTools.py
Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 666eda6

Please sign in to comment.