summaryrefslogtreecommitdiffstats
path: root/src/kernel/qapplication.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/qapplication.cpp')
-rw-r--r--src/kernel/qapplication.cpp45
1 files changed, 29 insertions, 16 deletions
diff --git a/src/kernel/qapplication.cpp b/src/kernel/qapplication.cpp
index 620f5df..fb531cb 100644
--- a/src/kernel/qapplication.cpp
+++ b/src/kernel/qapplication.cpp
@@ -600,8 +600,9 @@ static QPostEventList *globalPostedEvents = 0; // list of posted events
uint qGlobalPostedEventsCount()
{
- if (!globalPostedEvents)
+ if (!globalPostedEvents) {
return 0;
+ }
return globalPostedEvents->count();
}
@@ -2413,8 +2414,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)
@@ -2456,8 +2458,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:
@@ -2465,13 +2468,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
@@ -3275,8 +3280,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
@@ -3374,8 +3380,9 @@ void QApplication::postEvent( QObject *receiver, QEvent *event )
}
#endif
- if (currentEventLoop())
+ if (currentEventLoop()) {
currentEventLoop()->wakeUp();
+ }
}
@@ -3406,22 +3413,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
@@ -3438,7 +3448,7 @@ void QApplication::sendPostedEvents( QObject *receiver, int event_type )
|| receiver == pe->receiver ) // we send to THAT receiver
&& ( event_type == 0 // we send all types
|| event_type == pe->event->type() ) // we send THAT type
- && ( (!pe->receiver) || (pe->receiver->contextThreadObject() == QThread::currentThreadObject()) ) ) { // only send if active thread is receiver object owning thread
+ && ( (!pe->receiver) || ((pe->receiver) && (!pe->receiver->wasDeleted) && (pe->receiver->contextThreadObject() == QThread::currentThreadObject())) ) ) { // only send if active thread is receiver object owning thread
// first, we diddle the event so that we can deliver
// it, and that noone will try to touch it later.
pe->event->posted = FALSE;
@@ -3471,8 +3481,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 );
@@ -3493,10 +3504,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();
+ }
}
}
}