diff options
author | Timothy Pearson <[email protected]> | 2012-12-06 18:29:37 -0600 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2012-12-06 18:29:37 -0600 |
commit | caf80d88243aaa00e8f1baeaa6b7e4c3aca75f63 (patch) | |
tree | 860926c1e01068a8d3b8ea120630a48cf537424b /src/kernel | |
parent | 78125ea2f051107b84fdc0354acdedb7885308ee (diff) | |
download | qt3-caf80d88243aaa00e8f1baeaa6b7e4c3aca75f63.tar.gz qt3-caf80d88243aaa00e8f1baeaa6b7e4c3aca75f63.zip |
Add threading tutorial and fix a couple rare crashes
Diffstat (limited to 'src/kernel')
-rw-r--r-- | src/kernel/qapplication.cpp | 9 | ||||
-rw-r--r-- | src/kernel/qeventloop_unix.cpp | 2 | ||||
-rw-r--r-- | src/kernel/qeventloop_x11.cpp | 6 |
3 files changed, 13 insertions, 4 deletions
diff --git a/src/kernel/qapplication.cpp b/src/kernel/qapplication.cpp index a9c9fb8..f3b0119 100644 --- a/src/kernel/qapplication.cpp +++ b/src/kernel/qapplication.cpp @@ -2767,7 +2767,10 @@ bool QApplication::internalNotify( QObject *receiver, QEvent * e) if (!handled) { #if defined(QT_THREAD_SUPPORT) - bool locked = QApplication::qt_mutex->locked(); + bool locked = false; + if (QApplication::qt_mutex) { + locked = QApplication::qt_mutex->locked(); + } if (locked) { QApplication::qt_mutex->unlock(); } @@ -2775,7 +2778,9 @@ bool QApplication::internalNotify( QObject *receiver, QEvent * e) consumed = receiver->event( e ); #if defined(QT_THREAD_SUPPORT) if (locked) { - QApplication::qt_mutex->lock(); + if (QApplication::qt_mutex) { + QApplication::qt_mutex->lock(); + } } #endif } diff --git a/src/kernel/qeventloop_unix.cpp b/src/kernel/qeventloop_unix.cpp index 202ef12..80c8f29 100644 --- a/src/kernel/qeventloop_unix.cpp +++ b/src/kernel/qeventloop_unix.cpp @@ -562,6 +562,8 @@ int QEventLoop::activateTimers() n_act++; QTimerEvent e( t->id ); QApplication::sendEvent( t->obj, &e ); // send event + if ( !timerList ) // sendEvent allows other threads to execute, therefore we must check for list existence when it returns! + return 0; if ( timerList->findRef( begin ) == -1 ) begin = 0; } diff --git a/src/kernel/qeventloop_x11.cpp b/src/kernel/qeventloop_x11.cpp index cd3e865..5ee41ca 100644 --- a/src/kernel/qeventloop_x11.cpp +++ b/src/kernel/qeventloop_x11.cpp @@ -284,7 +284,8 @@ bool QEventLoop::processEvents( ProcessEventsFlags flags ) // unlock the GUI mutex and select. when we return from this function, there is // something for us to do #if defined(QT_THREAD_SUPPORT) - locker.mutex()->unlock(); + if ( locker.mutex() ) locker.mutex()->unlock(); + else return false; #endif int nsel; @@ -298,7 +299,8 @@ bool QEventLoop::processEvents( ProcessEventsFlags flags ) // relock the GUI mutex before processing any pending events #if defined(QT_THREAD_SUPPORT) - locker.mutex()->lock(); + if ( locker.mutex() ) locker.mutex()->lock(); + else return false; #endif // we are awake, broadcast it |