[Qt-interest] ASSERT failure in QMutex::unlock(): "A mutex must be unlocked in the same thread that locked it."
John McClurkin
jwm at nei.nih.gov
Fri Jul 16 14:50:26 CEST 2010
Sarvesh Saran wrote:
> 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();
>
> }
This is all very hard to understand since the indentation is all over
the map.
>
>
>
> And then later in the code I emit the signal:
Later in which code? What class is the sendValue signal a member of?
Only the class that owns a signal can 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
>
>
>
>
>
More information about the Qt-interest-old
mailing list