Skip to content
Permalink
Browse files

[processing] Correctly set parent widgets for algorithm dialogs

to avoid dialogs immediately going out of scope and being garbage
collected
  • Loading branch information
nyalldawson committed Nov 23, 2018
1 parent 2617fd5 commit 0e928e8191cd278009ccc3737d18f994693d7fa2
@@ -43,6 +43,7 @@
from qgis.PyQt.QtCore import Qt, QCoreApplication, QDir, QFileInfo
from qgis.PyQt.QtWidgets import QMenu, QAction
from qgis.PyQt.QtGui import QIcon, QKeySequence
from qgis.utils import iface

from processing.core.Processing import Processing
from processing.gui.AlgorithmDialog import AlgorithmDialog
@@ -86,7 +87,7 @@ def runAlg(file):
return False

alg.setProvider(QgsApplication.processingRegistry().providerById('model'))
dlg = AlgorithmDialog(alg)
dlg = AlgorithmDialog(alg, parent=iface.mainWindow())
dlg.show()
return True

@@ -95,9 +95,9 @@ def triggerResult(self, result):
dlg.setMessage(message)
dlg.exec_()
return
dlg = alg.createCustomParametersWidget(None)
dlg = alg.createCustomParametersWidget(parent=iface.mainWindow())
if not dlg:
dlg = AlgorithmDialog(alg)
dlg = AlgorithmDialog(alg, parent=iface.mainWindow())
canvas = iface.mapCanvas()
prevMapTool = canvas.mapTool()
dlg.show()
@@ -173,9 +173,9 @@ def triggerResult(self, result):

if [d for d in alg.parameterDefinitions() if
d.name() not in ('INPUT', 'OUTPUT')]:
dlg = alg.createCustomParametersWidget(None)
dlg = alg.createCustomParametersWidget(parent=iface.mainWindow())
if not dlg:
dlg = AlgorithmDialog(alg, True)
dlg = AlgorithmDialog(alg, True, parent=iface.mainWindow())
canvas = iface.mapCanvas()
prevMapTool = canvas.mapTool()
dlg.show()
@@ -250,9 +250,9 @@ def _executeAlgorithm(alg_id):
return

if (alg.countVisibleParameters()) > 0:
dlg = alg.createCustomParametersWidget(None)
dlg = alg.createCustomParametersWidget(parent=iface.mainWindow())
if not dlg:
dlg = AlgorithmDialog(alg)
dlg = AlgorithmDialog(alg, parent=iface.mainWindow())
canvas = iface.mapCanvas()
prevMapTool = canvas.mapTool()
dlg.show()
@@ -487,7 +487,7 @@ def runModel(self):
self.bar.pushMessage("", self.tr("Model doesn't contain any algorithm and/or parameter and can't be executed"), level=Qgis.Warning, duration=5)
return

dlg = AlgorithmDialog(self.model)
dlg = AlgorithmDialog(self.model, parent=iface.mainWindow())
dlg.exec_()

def save(self):
@@ -248,9 +248,9 @@ def runAlgorithm(self):
alg.setProvider(QgsApplication.processingRegistry().providerById("script"))
alg.initAlgorithm()

dlg = alg.createCustomParametersWidget(self)
dlg = alg.createCustomParametersWidget(iface.mainWindow())
if not dlg:
dlg = AlgorithmDialog(alg)
dlg = AlgorithmDialog(alg, parent=iface.mainWindow())

canvas = iface.mapCanvas()
prevMapTool = canvas.mapTool()
@@ -137,7 +137,7 @@ def createAlgorithmDialog(algOrName, parameters={}):
dlg = alg.createCustomParametersWidget(iface.mainWindow())

if not dlg:
dlg = AlgorithmDialog(alg)
dlg = AlgorithmDialog(alg, parent=iface.mainWindow())

dlg.setParameters(parameters)

0 comments on commit 0e928e8

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