Skip to content

Commit a17ed10

Browse files
committed
fix vector menu creation on qt5
1 parent 71429be commit a17ed10

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

python/plugins/processing/gui/menus.py

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from processing.core.Processing import Processing
22
from processing.core.ProcessingConfig import ProcessingConfig, Setting
3-
from PyQt4.QtGui import QAction, QMenu
3+
from PyQt.QtWidgets import QAction, QMenu
44
from processing.gui.MessageDialog import MessageDialog
55
from processing.gui.AlgorithmDialog import AlgorithmDialog
66
from qgis.utils import iface
@@ -117,17 +117,17 @@ def updateMenus():
117117

118118

119119
def createMenus():
120-
for provider in Processing.algs.values():
121-
for alg in provider.values():
120+
for provider in list(Processing.algs.values()):
121+
for alg in list(provider.values()):
122122
menuPath = ProcessingConfig.getSetting("MENU_" + alg.commandLineName())
123123
if menuPath:
124124
paths = menuPath.split("/")
125125
addAlgorithmEntry(alg, paths[0], paths[-1])
126126

127127

128128
def removeMenus():
129-
for provider in Processing.algs.values():
130-
for alg in provider.values():
129+
for provider in list(Processing.algs.values()):
130+
for alg in list(provider.values()):
131131
menuPath = ProcessingConfig.getSetting("MENU_" + alg.commandLineName())
132132
if menuPath:
133133
paths = menuPath.split("/")
@@ -196,14 +196,11 @@ def _executeAlgorithm(alg):
196196

197197

198198
def getMenu(name, parent):
199-
menus = [c for c in parent.children() if isinstance(c, QMenu)]
200-
menusDict = {m.title(): m for m in menus}
201-
if name in menusDict:
202-
return menusDict[name]
199+
menus = [c for c in parent.children() if isinstance(c, QMenu) and c.title() == name]
200+
if menus:
201+
return menus[0]
203202
else:
204-
menu = QMenu(name, parent)
205-
parent.addMenu(menu)
206-
return menu
203+
return parent.addMenu(name)
207204

208205

209206
def findAction(actions, alg, actionText=None):

0 commit comments

Comments
 (0)