PDA

View Full Version : Problems with a Thread



avis_phoenix
6th February 2009, 02:09
Hi

I tried to restart a thread (after exit them), but when I push the restart button the program crashed and the debuger showed the following message: "QObject: Cannot create children for a parent that is in a different thread.(Parent is QTcpSocket(0x811a274), parent's thread is QThread(0x81367c0), current thread is OptimizationThread(0x81a6d90)"

What could be the problem?

The code to restart is this:


pause = false;
if (!isRunning())
{
start(QThread::LowPriority);
}
else
{
condition.wakeOne();
quit();
if (!isRunning())
{
start(QThread::LowPriority);
}
else
{
qDebug()<<"Error";
}
}


I use Qt 4.4.3 and ubuntu

jpn
6th February 2009, 14:28
Could you show more code? You've got a bug there, but it's hard to say without seeing more code. Be especially careful with slots in QThread subclasses. You can search the forums for more details on the subject.

avis_phoenix
6th February 2009, 22:59
Ok, I Attach the code for the thread and the dialog uses this thread. :)

Thanks you

jpn
8th February 2009, 17:11
Ok, how about defining QT_FATAL_WARNINGS=1 environment variable and getting the backtrace from a debugger?