<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#006600">
<p>Thank you, Arnaud!</p>
<p>you confirm my last choice.</p>
<p>It works perfectly!</p>
<p>enrico<br>
</p>
<br>
<div class="moz-cite-prefix">Il 27/03/2017 09:28, Arnaud Morvan ha
scritto:<br>
</div>
<blockquote
cite="mid:ff95908f-c277-9bff-e138-c0a74ec4f131@camptocamp.com"
type="cite">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<p>Hello Enrico,</p>
<p>Do not change the common dialog closeEvent Method, you should
subclass it.</p>
<p>class MyCustomDialog(AlgorithmDialog):</p>
<p> ...<br>
</p>
<p>You can give a custom dialog to you algorithm using
GeoAlgorithm.<span class="pl-en">getCustomParametersDialog</span>
method.</p>
<p>class MyAlgorithm(GeoAlgorithm):</p>
<p> ...</p>
<p> def <span class="pl-en">getCustomParametersDialog(self):</span></p>
<p><span class="pl-en"> return </span>MyCustomDialog()</p>
<p><br>
</p>
<p>Do not forget to call the base AlgorithmDialog.closeEvent
method in yours :</p>
<p>class MyCustomDialog(AlgorithmDialog):</p>
<p> def closeEvent(self):<br>
</p>
<p> super(MyCustomDialog, self).closeEvent()</p>
<p><br>
</p>
<p>This is the way to execute custom tasks in the closeEvent, I do
not say that this the better way for your job.<br>
</p>
<p>Cheers<br>
</p>
<pre class="moz-signature" cols="72">Arnaud Morvan
Ingénieur logiciel
Tél: +33 (0)4 58 48 20 32
Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac Cedex
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.camptocamp.com">http://www.camptocamp.com</a></pre>
<div class="moz-cite-prefix">Le 23/03/2017 à 18:14, enrico
chiaradia a écrit :<br>
</div>
<blockquote
cite="mid:1c9d634b-f21d-7832-6b45-08a94b08eaca@yahoo.it"
type="cite">
<meta http-equiv="content-type" content="text/html;
charset=utf-8">
<p>Dear (processing) developers,</p>
<p>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.</p>
<p>I though to overload the closeEvent in this way:</p>
<p>from processing.gui.AlgorithmDialog import AlgorithmDialog<br>
</p>
<p>[omitted]</p>
<p>class ExportTilesAlgorithm(GeoAlgorithm):</p>
<p> [omitted]</p>
<p> # get the AlgorithmDialog dialog object and overload the
closeEvent<br>
AlgorithmDialog.closeEvent = self.closeEvent<br>
</p>
<p> [omitted]<br>
</p>
def closeEvent(self, evt):<br>
# necessary to close the thread before it is finished<br>
self.workThread.stop()
<p>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) :</p>
<p>def closeEvent(self, evt):<br>
QgsMapLayerRegistry.instance().layerWasAdded.disconnect(self.mainWidget.layerAdded)<br>
QgsMapLayerRegistry.instance().layersWillBeRemoved.disconnect(self.mainWidget.layersWillBeRemoved)<br>
super(AlgorithmDialog, self).closeEvent(evt)<br>
</p>
<p>Any suggestions?</p>
<p>Thank you</p>
<p>enrico<br>
</p>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Qgis-developer mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a>
List info: <a moz-do-not-send="true" class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
Unsubscribe: <a moz-do-not-send="true" class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a></pre>
</blockquote>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Qgis-developer mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a>
List info: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a></pre>
</blockquote>
<br>
</body>
</html>