<HTML>
<HEAD>
<TITLE>Re: [PyQt] Qthread segmentation fault</TITLE>
</HEAD>
<BODY>
<FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>There was a similar message just a a day or so ago. For this particular application, you don’t need threads. However, you probably don’t want that answer.<BR>
<BR>
It looks like you are creating the socket in one thread and using it in both the main and worker threads. I believe you should be only using the socket in the worker thread and then communicating back to the main thread and you should <B>never</B> directly or indirectly use a QWidget based object from the thread.<BR>
<BR>
>From the docs: <a href="http://doc.trolltech.com/4.4/qthread.html">http://doc.trolltech.com/4.4/qthread.html</a><BR>
<BR>
</SPAN></FONT><FONT FACE="Times, Times New Roman"><SPAN STYLE='font-size:12pt'>Note, however, that it is not possible to use any widget classes in the thread.<BR>
</SPAN></FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
My suggestion is to (1) don’t use threads or (2) have the socket only in the qthread class and communicate your data back to the gui classes using signals or through another mechanism.<BR>
<BR>
Quite honestly the IO of your program is small enough you could just use a QTimer to poll the socket periodically. You would probably want to have some type of sleep in your thread anyway since as written this would consume 100% cpu :)<BR>
<BR>
Brian Kelley</SPAN></FONT>
</BODY>
</HTML>