@@ -90,6 +90,9 @@ def __init__(self, iface):
90
90
self .translator .load (self .localePath )
91
91
QCoreApplication .installTranslator (self .translator )
92
92
93
+ # The list of actions added to menus, so we can remove them when unloading the plugin
94
+ self ._menuActions = []
95
+
93
96
def initGui (self ):
94
97
if not valid :
95
98
return
@@ -123,7 +126,7 @@ def initGui(self):
123
126
menu_bar .insertMenu (lastAction , self .menu )
124
127
else :
125
128
self .menu = rasterMenu
126
- self .menu .addSeparator ()
129
+ self ._menuActions . append ( self . menu .addSeparator () )
127
130
128
131
# projections menu (Warp (Reproject), Assign projection)
129
132
self .projectionsMenu = QMenu (QCoreApplication .translate ("GdalTools" , "Projections" ), self .iface .mainWindow ())
@@ -280,25 +283,27 @@ def initGui(self):
280
283
281
284
self .miscellaneousMenu .addActions ([self .merge , self .info , self .overview , self .tileindex ])
282
285
283
- self .menu .addMenu (self .projectionsMenu )
284
- self .menu .addMenu (self .conversionMenu )
285
- self .menu .addMenu (self .extractionMenu )
286
+ self ._menuActions . append ( self . menu .addMenu (self .projectionsMenu ) )
287
+ self ._menuActions . append ( self . menu .addMenu (self .conversionMenu ) )
288
+ self ._menuActions . append ( self . menu .addMenu (self .extractionMenu ) )
286
289
287
290
if not self .analysisMenu .isEmpty ():
288
- self .menu .addMenu (self .analysisMenu )
291
+ self ._menuActions . append ( self . menu .addMenu (self .analysisMenu ) )
289
292
290
- self .menu .addMenu (self .miscellaneousMenu )
293
+ self ._menuActions . append ( self . menu .addMenu (self .miscellaneousMenu ) )
291
294
292
295
self .settings = QAction (QCoreApplication .translate ("GdalTools" , "GdalTools Settings..." ), self .iface .mainWindow ())
293
296
self .settings .setObjectName ("settings" )
294
297
self .settings .setStatusTip (QCoreApplication .translate ("GdalTools" , "Various settings for Gdal Tools" ))
295
298
QObject .connect (self .settings , SIGNAL ("triggered()" ), self .doSettings )
296
299
self .menu .addAction (self .settings )
300
+ self ._menuActions .append (self .settings )
297
301
298
302
def unload (self ):
299
303
if not valid :
300
304
return
301
- pass
305
+ for a in self ._menuActions :
306
+ self .menu .removeAction (a )
302
307
303
308
def doBuildVRT (self ):
304
309
from tools .doBuildVRT import GdalToolsDialog as BuildVRT
0 commit comments