Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
4.7.2
Description
In the QMutexLocker documentation the before and after example code would run with a significant difference. The version that directly locks QMutex unlocks BEFORE running moreComplexFunction(), but when using QMutexLocker the lock would be held during that function call. The QMutex version:
mutex.lock();
int retVal = 0;
switch {
case 0:
case 1:
mutex.unlock();
return moreComplexFunction;
vs. the QMutexLocker version:
QMutexLocker locker(&mutex);
int retVal = 0;
switch {
case 0:
case 1:
return moreComplexFunction;
Since this relies on the C++ compiler to handle scoping to test this I wrote and ran:
#include <stdio.h>
class dummy
{
public:
dummy()Unknown macro: { printf("creating dummyn"); }~dummy()
Unknown macro: { printf("deleting dummyn"); }};
int callMe()
{
printf("called callMe\n");
return 42;
}int main(int argc, char **argv)
{
dummy a;
return callMe();
}
The output was as expected:
[jdunn@temp QtOpenCV]$ ./test
creating dummy
called callMe
deleting dummy
Also, your bug reporting interface doesn't appear to support a tag to quote code well.