summaryrefslogtreecommitdiffstats
path: root/src/moc
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-05-14 19:34:10 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-05-14 19:34:10 -0500
commit4eba9b823832a5bab1acffeabc245b06fe113d75 (patch)
tree9ec81ead726a66066c6450c805beb8e233391a65 /src/moc
parentbe8413249bb8a6d8dc2cfc693d9c1037284fd251 (diff)
downloadqt3-4eba9b823832a5bab1acffeabc245b06fe113d75.tar.gz
qt3-4eba9b823832a5bab1acffeabc245b06fe113d75.zip
Fix a number of threading data races
Add proper thread termination handler This partially resolves Bug 1508
Diffstat (limited to 'src/moc')
-rw-r--r--src/moc/moc.y5
-rw-r--r--src/moc/moc_yacc.cpp5
2 files changed, 8 insertions, 2 deletions
diff --git a/src/moc/moc.y b/src/moc/moc.y
index 316efba..a507126 100644
--- a/src/moc/moc.y
+++ b/src/moc/moc.y
@@ -2986,7 +2986,9 @@ void generateClass() // generate C++ source code for a class
// Generate staticMetaObject member function
//
fprintf( out, "QMetaObject* %s::staticMetaObject()\n{\n", (const char*)qualifiedClassName() );
- fprintf( out, " if ( metaObj )\n\treturn metaObj;\n" );
+ fprintf( out, " if ( metaObj ) {\n\treturn metaObj;\n}\n" );
+ fprintf( out, "#ifdef QT_THREAD_SUPPORT\n if (qt_sharedMetaObjectMutex) qt_sharedMetaObjectMutex->lock();\n" );
+ fprintf( out, " if ( metaObj ) {\n\tif (qt_sharedMetaObjectMutex) qt_sharedMetaObjectMutex->unlock();\n\treturn metaObj;\n }\n#endif // QT_THREAD_SUPPORT\n" );
if ( isQObject )
fprintf( out, " QMetaObject* parentObject = staticQtMetaObject();\n" );
else if ( !g->superClassName.isEmpty() )
@@ -3056,6 +3058,7 @@ void generateClass() // generate C++ source code for a class
// Setup cleanup handler and return meta object
//
fprintf( out, " cleanUp_%s.setMetaObject( metaObj );\n", cleanup.data() );
+ fprintf( out, "#ifdef QT_THREAD_SUPPORT\n if (qt_sharedMetaObjectMutex) qt_sharedMetaObjectMutex->unlock();\n#endif // QT_THREAD_SUPPORT\n" );
fprintf( out, " return metaObj;\n}\n" );
//
diff --git a/src/moc/moc_yacc.cpp b/src/moc/moc_yacc.cpp
index b30fa23..cb307e6 100644
--- a/src/moc/moc_yacc.cpp
+++ b/src/moc/moc_yacc.cpp
@@ -5812,7 +5812,9 @@ void generateClass() // generate C++ source code for a class
// Generate staticMetaObject member function
//
fprintf( out, "QMetaObject* %s::staticMetaObject()\n{\n", (const char*)qualifiedClassName() );
- fprintf( out, " if ( metaObj )\n\treturn metaObj;\n" );
+ fprintf( out, " if ( metaObj ) {\n\treturn metaObj;\n}\n" );
+ fprintf( out, "#ifdef QT_THREAD_SUPPORT\n if (qt_sharedMetaObjectMutex) qt_sharedMetaObjectMutex->lock();\n" );
+ fprintf( out, " if ( metaObj ) {\n\tif (qt_sharedMetaObjectMutex) qt_sharedMetaObjectMutex->unlock();\n\treturn metaObj;\n }\n#endif // QT_THREAD_SUPPORT\n" );
if ( isQObject )
fprintf( out, " QMetaObject* parentObject = staticQtMetaObject();\n" );
else if ( !g->superClassName.isEmpty() )
@@ -5882,6 +5884,7 @@ void generateClass() // generate C++ source code for a class
// Setup cleanup handler and return meta object
//
fprintf( out, " cleanUp_%s.setMetaObject( metaObj );\n", cleanup.data() );
+ fprintf( out, "#ifdef QT_THREAD_SUPPORT\n if (qt_sharedMetaObjectMutex) qt_sharedMetaObjectMutex->unlock();\n#endif // QT_THREAD_SUPPORT\n" );
fprintf( out, " return metaObj;\n}\n" );
//