<p dir="ltr">Hi Sergio,</p>
<p dir="ltr">It sounds like a new problem. Did removing the return fix the crash problem that happened before? As your problem now that it prints double letters, I am sure that you just need to clear some component's state before running the worker.</p>
<p dir="ltr">Do you have the plugin somewhere on github? If you have, I'll try it myself</p>
<p dir="ltr">Cheers</p>
<div class="gmail_extra"><br><div class="gmail_quote">On Sep 14, 2016 00:07, "Sergio Vignali" <<a href="mailto:vignalisergio30@gmail.com">vignalisergio30@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Akbar,<br><br>as you suggested I removed return but it didn't solve the problem...<br>I don't get it because when I open the dialog the first time I can play with it changing word without problem<br>(I mean that I can insert a new word several time and when I push apply everything works well).<br>I think it's something that I should destroy when closing the dialog... but I don't find what!<br>Two strange behaviours that I found is that sometimes after restarting the dialog if I insert the same word I inserted during the<br>last run the plugin works well or if I change word it writes double items, like digiting "et" it inserts "ee" and "tt" and after it crashes, but how it gets<br>the double letters in the loop?...<br>It's for sure something related to the restarting as if I use the plugin reload it doesn't crash...<br>Any idea? Anyway thanks for your suggestion!<br><br>All the best<br>s.<br></div><div class="gmail_extra"><br><div class="gmail_quote">2016-09-10 10:42 GMT+02:00 Sergio Vignali <span dir="ltr"><<a href="mailto:vignalisergio30@gmail.com" target="_blank">vignalisergio30@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Hi Akbar, <br>
thank you for your answer, I'm abroad till Tuesday but I will test it asap and let you know. <br>
Best</p><div><div>
<div class="gmail_extra"><br><div class="gmail_quote">Il 09/set/2016 05:04, "Akbar Gumbira" <<a href="mailto:akbargumbira@gmail.com" target="_blank">akbargumbira@gmail.com</a>> ha scritto:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Sergio, <div><br></div><div>DId you fix already your problems? I am not sure if my answer is 100% correct (so I don't post it in stackexchange) as  I didnt try it, but by judging your code:</div><div><span style="font-size:15px"><br></span></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span style="font-size:15px">If I click apply without entering anything in the QLineEdit the QgsMessageBar appears correctly but if I close the QDialog and I do the same the QgisMessageBar has two items (1 more, see picture)</span></blockquote><div><br></div><div>Plugins initiallization happened when starting QGIS. So the plugin is already instantiated (along with your dialog, message bar, etc). Restarting (that is closing and opening again) the dialog in your code doesn't destroy all the instances. That is why the message bar has the previous messages. You can just clear the message bar once user opens the dialog.</div><div><span style="color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif;font-size:15px;line-height:19.5px;background-color:rgba(248,248,248,0.6)"><br></span></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span style="color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif;font-size:15px;line-height:19.5px;background-color:rgba(248,248,248,0.6)">If I insert a word in the QLineEdit after opening the plugin for the second time, clicking on apply Qgis crashes.</span></blockquote><div><br></div><div>This is not necessarily related to the crash :p:</div><div><ul><li><pre style="margin-top:0px;margin-bottom:1em;padding:5px;border:0px;font-size:13px;width:auto;max-height:600px;overflow:auto;font-family:consolas,menlo,monaco,"lucida console","liberation mono","dejavu sans mono","bitstream vera sans mono","courier new",monospace,sans-serif;word-wrap:normal;color:rgb(36,39,41);background-color:rgb(239,240,241)"><code style="margin:0px;padding:0px;border:0px;font-family:consolas,menlo,monaco,"lucida console","liberation mono","dejavu sans mono","bitstream vera sans mono","courier new",monospace,sans-serif;white-space:inherit">word = unicode(self.dlg.inputedit.tex<wbr>t())</code></pre></li></ul></div>But QString is stored in unicode, no need to recast it</div><div><br></div><div>For the cause of the crash, I strongly believe this is the problem:</div><div><pre style="margin-top:0px;margin-bottom:1em;padding:5px;border:0px;font-size:13px;width:auto;max-height:600px;overflow:auto;font-family:consolas,menlo,monaco,"lucida console","liberation mono","dejavu sans mono","bitstream vera sans mono","courier new",monospace,sans-serif;word-wrap:normal;color:rgb(36,39,41);background-color:rgb(239,240,241)"><code style="margin:0px;padding:0px;border:0px;font-family:consolas,menlo,monaco,"lucida console","liberation mono","dejavu sans mono","bitstream vera sans mono","courier new",monospace,sans-serif;white-space:inherit">    def add_item(self, item):
        self.list.addItem(item)
        return</code></pre></div><div>Can you try to remove return there? I think it's forcing the thread to go back to the main loop (plugin Run method)</div><div><br></div><div>Cheers</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 7, 2016 at 1:57 PM, Sergio Vignali <span dir="ltr"><<a href="mailto:vignalisergio30@gmail.com" target="_blank">vignalisergio30@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>I posted my problem in gis.stackexchange, (<a href="http://gis.stackexchange.com/questions/209602/qgis-crash-using-qthread-in-a-plugin-script" target="_blank">http://gis.stackexchange.com/<wbr>questions/209602/qgis-crash-us<wbr>ing-qthread-in-a-plugin-script</a><wbr>).<br>There you can find the full explanation of the problem and all the code I used... It would be great to get some feedbacks!<br></div>Best<br></div>s.<br></div><div class="gmail_extra"><div><div><br><div class="gmail_quote">2016-09-06 3:58 GMT+02:00 Akbar Gumbira <span dir="ltr"><<a href="mailto:akbargumbira@gmail.com" target="_blank">akbargumbira@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">It would be more helpful if you point to the code here. I had a problem with QThread (was initially inheriting QThread) but managed to fix the problem by creating workers and move the worker object to thread. This is a good article about multithreading in qgis<a href="https://snorfalorpagus.net/blog/2013/12/07/multithreading-in-qgis-python-plugins/" target="_blank"> https://snorfalorpagus.net/blo<wbr>g/2013/12/07/multithreading-in<wbr>-qgis-python-plugins/</a></p>
<div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Sep 5, 2016 23:01, "Sergio Vignali" <<a href="mailto:vignalisergio30@gmail.com" target="_blank">vignalisergio30@gmail.com</a>> wrote:<br type="attribution"></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><div>Dear all,<br><br>I wrote a python script that aims to execute neighbourhood statistics in raster layer. My script uses QThread to update a QList and a QProgressBar and everithing works fine if I run the script from PyCharm, the progressbar and the list are updated. The problem appears when I move my script in a Qgis plugin, the UI appears correctly but clicking OK the software crashes...<br>I am using qgis 2.14 in a linux machine, do you have any advice?<br><br>All the best<br><br></div><br clear="all"><div><div><div><div><br>-- <br><div><div dir="ltr">Sergio Vignali<div><br></div></div></div>
</div></div></div></div></div>
<br></div></div>______________________________<wbr>_________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a><br>
List info: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman<wbr>/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman<wbr>/listinfo/qgis-developer</a><br></blockquote></div></div>
</blockquote></div><br><br clear="all"><br></div></div><span><font color="#888888">-- <br><div data-smartmail="gmail_signature"><div dir="ltr">Sergio Vignali<div><br></div></div></div>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><p><b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">-------------------</span></b></p><b>Akbar Gumbira </b></div><div><b style="font-size:12.8px"><a href="http://www.akbargumbira.com" target="_blank">www.akbargumbira.com</a></b></div></div></div></div></div>
</div>
</blockquote></div></div>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div data-smartmail="gmail_signature"><div dir="ltr">Sergio Vignali<div><br></div></div></div>
</div>
</blockquote></div></div>