-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
4.6.0
-
None
-
*Windows XP Professional - 32bit*
*Visual Studio 2005 Professional*
*Qt 4.6.0*
I have created a simple application that demonstrates this error/behavior. The application is called qtThreads.exe and the source is listed at the bottom of this post.
In the following examples the application is being run from a Windows console.
See similar problem with QReadWriteLock: QTBUG-7886
Example #1 - Works as expected
qtThreads.exe && echo Test Complete
- Output:
Non-Threaded Test Complete
Example #2 - Generates warning
qtThreads.exe wait && echo Test Complete
- Output:
Threaded QWaitCondition: Destroyed while threads are still waiting Test Complete
Example #3 - Generates deadlock
qtThreads.exe nowait && echo Test Complete
- Output:
Threaded
Source Code:
#include <QtCore/QtConcurrentRun>
#include <QtCore/QMutex>
#include <iostream>
void foo()
{
QMutex lock;
lock.lock();
lock.unlock();
}
int main(int argc, char* argv[])
{
if (argc > 1)
{
std::cerr << "Threaded\n";
QFuture<void> future = QtConcurrent::run(&foo);
if (strcmp(argv[1], "wait") == 0)
{
future.waitForFinished();
}
}
else
{
std::cerr << "Non-Threaded\n";
foo();
}
return 0;
}