diff options
| author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-04-22 21:25:32 -0500 |
|---|---|---|
| committer | Slávek Banko <slavek.banko@axis.cz> | 2013-04-25 03:21:44 +0200 |
| commit | b8e4f241c05530146a21c03d9b936fe288b5d9b2 (patch) | |
| tree | 2a220da0599e46bcdc3c5fdcf18a0568d91b7b67 /src/kernel/qapplication.cpp | |
| parent | 60621ef099afb930228089c12c98565d22c1c831 (diff) | |
| download | qt3-b8e4f241c05530146a21c03d9b936fe288b5d9b2.tar.gz qt3-b8e4f241c05530146a21c03d9b936fe288b5d9b2.zip | |
Fix a number of threading problems and crashes
This partially resolves Bug 1467
(part of the original commit)
(cherry picked from commit 83d39cad274f592a43a3262926d215493caea0bc)
Diffstat (limited to 'src/kernel/qapplication.cpp')
| -rw-r--r-- | src/kernel/qapplication.cpp | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/src/kernel/qapplication.cpp b/src/kernel/qapplication.cpp index 0ec4904..960db1e 100644 --- a/src/kernel/qapplication.cpp +++ b/src/kernel/qapplication.cpp @@ -546,8 +546,9 @@ static QPostEventList *globalPostedEvents = 0; // list of posted events uint qGlobalPostedEventsCount() { - if (!globalPostedEvents) + if (!globalPostedEvents) { return 0; + } return globalPostedEvents->count(); } @@ -2315,8 +2316,9 @@ void QApplication::aboutQt() bool QApplication::notify( QObject *receiver, QEvent *e ) { // no events are delivered after ~QApplication() has started - if ( is_app_closing ) + if ( is_app_closing ) { return FALSE; + } if ( receiver == 0 ) { // serious error #if defined(QT_CHECK_NULL) @@ -2358,8 +2360,9 @@ bool QApplication::notify( QObject *receiver, QEvent *e ) } bool res = FALSE; - if ( !receiver->isWidgetType() ) + if ( !receiver->isWidgetType() ) { res = internalNotify( receiver, e ); + } else switch ( e->type() ) { #ifndef QT_NO_ACCEL case QEvent::Accel: @@ -2367,13 +2370,15 @@ bool QApplication::notify( QObject *receiver, QEvent *e ) QKeyEvent* key = (QKeyEvent*) e; res = internalNotify( receiver, e ); - if ( !res && !key->isAccepted() ) + if ( !res && !key->isAccepted() ) { res = qt_dispatchAccelEvent( (QWidget*)receiver, key ); + } // next lines are for compatibility with Qt <= 3.0.x: old // QAccel was listening on toplevel widgets - if ( !res && !key->isAccepted() && !((QWidget*)receiver)->isTopLevel() ) + if ( !res && !key->isAccepted() && !((QWidget*)receiver)->isTopLevel() ) { res = internalNotify( ((QWidget*)receiver)->topLevelWidget(), e ); + } } break; #endif //QT_NO_ACCEL @@ -3116,8 +3121,9 @@ void QApplication::postEvent( QObject *receiver, QEvent *event ) qapp_cleanup_events.set( &globalPostedEvents ); } - if ( !receiver->postedEvents ) + if ( !receiver->postedEvents ) { receiver->postedEvents = new QPostEventList; + } QPostEventList * l = receiver->postedEvents; // if this is one of the compressible events, do compression @@ -3232,22 +3238,25 @@ void QApplication::sendPostedEvents( QObject *receiver, int event_type ) { // Make sure the object hierarchy is stable before processing events // to avoid endless loops - if ( receiver == 0 && event_type == 0 ) + if ( receiver == 0 && event_type == 0 ) { sendPostedEvents( 0, QEvent::ChildInserted ); - - if ( !globalPostedEvents || ( receiver && !receiver->postedEvents ) ) - return; + } #ifdef QT_THREAD_SUPPORT QMutexLocker locker( postevent_mutex ); #endif + if ( !globalPostedEvents || ( receiver && !receiver->postedEvents ) ) { + return; + } + bool sent = TRUE; while ( sent ) { sent = FALSE; - if ( !globalPostedEvents || ( receiver && !receiver->postedEvents ) ) + if ( !globalPostedEvents || ( receiver && !receiver->postedEvents ) ) { return; + } // if we have a receiver, use the local list. Otherwise, use the // global list @@ -3296,8 +3305,9 @@ void QApplication::sendPostedEvents( QObject *receiver, int event_type ) if ( e->type() == QEvent::Paint && r->isWidgetType() ) { QWidget * w = (QWidget*)r; QPaintEvent * p = (QPaintEvent*)e; - if ( w->isVisible() ) + if ( w->isVisible() ) { w->repaint( p->reg, p->erase ); + } } else { sent = TRUE; QApplication::sendEvent( r, e ); @@ -3318,10 +3328,12 @@ void QApplication::sendPostedEvents( QObject *receiver, int event_type ) if ( l == globalPostedEvents ) { globalPostedEvents->first(); while( (pe=globalPostedEvents->current()) != 0 ) { - if ( pe->event ) + if ( pe->event ) { globalPostedEvents->next(); - else + } + else { globalPostedEvents->remove(); + } } } } |
