[Qt-interest] ASSERT failure in QMutex::unlock(): "A mutex must be unlocked in the same thread that locked it."

Sarvesh Saran Sarvesh.Saran at synopsys.com
Fri Jul 16 06:27:59 CEST 2010


Hi All,

As a multi threading newbie I have been struggling with this particular error message for some time now:

ASSERT failure in QMutex::unlock(): "A mutex must be unlocked in the same thread that locked it."

It pops up when I exit my application.How do I begin to debug this?

I also have a question about queued connections between objects in QT.
Assume I have a MY Thread object  :

MYClass::startAthread()                                                                                                                                                               MyThread::setValue(int val)
{
{                                                                                                                                                                                                                              mutex.lock();
MyThread a = new MyThread(this); //this inherits QThread                                                                                                         _val = val;

Connect(this,SIGNAL(sendValue(int)),a,SLOT(setValue(a)));                                                                                                       mutex.unlock();  //I suspect the error is somewhere here....
                                                                                                                                                                                                                }
a->start();
}

And then later in the code I emit the signal:

emit sendValue(10);  //who executes setValue slot? Is it the MyCLass object or is it the MyThread object a ?)

if I instead directly call :

sendValue(10); //no emit, is this different from the above?

Kindly help me out here..

Thanks,
Sarvesh


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100716/a03ea9d3/attachment.html 


More information about the Qt-interest-old mailing list