[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 18:36:41 CEST 2010
Hi,
Sorry for the poor indentation. Let me rephrase:
I am simply having a tough time understanding how signals and slots work across threads.
Assume that I have a MyThread:QThread object called A running and it contains a public slot setValue().
//this code is in the main window
MyThread *a = new MyThread; //create the thread
connect(this,sendValue(int),a,setValue(int)));
later in the code I emit a signal:
emit sendValue(10);
I would like to know how this emit is different from:
a->setValue(10) ?
in either case, who executes the slot setValue? Is it the MainWindow thread or MyThread?
Thanks,
Sarvesh
-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of John McClurkin
Sent: Friday, July 16, 2010 6:20 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] ASSERT failure in QMutex::unlock(): "A mutex must be unlocked in the same thread that locked it."
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
>
>
>
>
>
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list