[Qgis-developer] overload closeEvent in AlgorithmDialog.py

enrico chiaradia enrico.chiaradia at yahoo.it
Thu Mar 23 10:14:35 PDT 2017


Dear (processing) developers,

for my plugin (IO Geopaparazzi), I need to stop the execution of an 
external thread when the user presses the X button of the form.

I though to overload the closeEvent in this way:

from processing.gui.AlgorithmDialog import AlgorithmDialog

[omitted]

class ExportTilesAlgorithm(GeoAlgorithm):

     [omitted]

     # get the AlgorithmDialog dialog object and overload the closeEvent
     AlgorithmDialog.closeEvent = self.closeEvent

     [omitted]

     def closeEvent(self, evt):
        # necessary to close the thread before it is finished
        self.workThread.stop()

it works perfectly but I'm not sure that it will not induce anomalous 
behaviours in other geoalgorithms as the original function is (from 
AlgorithmDialog.py) :

def closeEvent(self, evt):
QgsMapLayerRegistry.instance().layerWasAdded.disconnect(self.mainWidget.layerAdded)
QgsMapLayerRegistry.instance().layersWillBeRemoved.disconnect(self.mainWidget.layersWillBeRemoved)
         super(AlgorithmDialog, self).closeEvent(evt)

Any suggestions?

Thank you

enrico

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20170323/0057344a/attachment.html>


More information about the Qgis-developer mailing list