Hey there,
I've implemented a QThread.
Here is my run function:
void qkReceptor::run()
{
// A timer to avoid high CPU charge
connect(&timer, SIGNAL(timeout()), this, SLOT(onCheckStdin()), Qt::DirectConnection);
connect(this,
SIGNAL(newLine
(QString)),
this,
SLOT(onNewLine
(QString)), Qt
::BlockingQueuedConnection);
timer.start(100);
}
void qkReceptor::run()
{
// A timer to avoid high CPU charge
QTimer timer;
connect(&timer, SIGNAL(timeout()), this, SLOT(onCheckStdin()), Qt::DirectConnection);
connect(this, SIGNAL(newLine(QString)), this, SLOT(onNewLine(QString)), Qt::BlockingQueuedConnection);
timer.start(100);
QThread::exec();
}
To copy to clipboard, switch view to plain text mode
Here is my stop function:
void qkReceptor::stop()
{
QThread::wait();
// Infinite loop here }
void qkReceptor::stop()
{
QThread::quit();
QThread::wait(); // Infinite loop here
}
To copy to clipboard, switch view to plain text mode
When calling stop from my main thread, wait blocks everything.
Why?
Thanks.
Bookmarks