I can only suggest that you use a wait condition to stop the emiting thread and release it from a slot. It's still a bad design though, because you may experience unwanted behaviour when two objects are connected to that signal.
connect(thread, SIGNAL(someSignal()), someother, SLOT(someSlot()));
//...
void MyThread::someMethod(){
m.lock();
emit someSignal();
wcond.wait(&m);
m.unlock();
}
//...
void OtherClass::someSlot(){
doSomething();
wcond.wakeAll();
}
QMutex m;
QWaitCondition wcond;
connect(thread, SIGNAL(someSignal()), someother, SLOT(someSlot()));
//...
void MyThread::someMethod(){
m.lock();
emit someSignal();
wcond.wait(&m);
m.unlock();
}
//...
void OtherClass::someSlot(){
doSomething();
wcond.wakeAll();
}
To copy to clipboard, switch view to plain text mode
I don't know what will happen if the slot will be called immediately after emit someSignal(), before wcond.wait() -- you might end up in a deadlock. You might want to take a look at QWaitCondition docs to see how to avoid it.
Bookmarks