Streamline forwarding of blocked events.
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>
Tue, 4 Sep 2012 07:45:04 +0000 (09:45 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 11 Sep 2012 05:00:31 +0000 (07:00 +0200)
Do not send to layouts, invoke modalWidget() only once.

Task-number: QTBUG-27039
Change-Id: I96db02c8da544d0961c8ab25505926ac6f699342
Reviewed-by: Qt Doc Bot <qt_docbot@qt-project.org>
Reviewed-by: hjk <qthjk@ovi.com>
src/widgets/kernel/qwidget.cpp

index c5f033c..f929271 100644 (file)
@@ -8147,23 +8147,21 @@ bool QWidget::event(QEvent *event)
 
     case QEvent::WindowBlocked:
     case QEvent::WindowUnblocked:
-        {
-            QList<QObject*> childList = d->children;
-            for (int i = 0; i < childList.size(); ++i) {
-                QObject *o = childList.at(i);
-                if (o && o != QApplication::activeModalWidget()) {
-                    if (qobject_cast<QWidget *>(o) && static_cast<QWidget *>(o)->isWindow()) {
-                        // do not forward the event to child windows,
-                        // QApplication does this for us
-                        continue;
-                    }
-                    QApplication::sendEvent(o, event);
+        if (!d->children.isEmpty()) {
+            QWidget *modalWidget = QApplication::activeModalWidget();
+            for (int i = 0; i < d->children.size(); ++i) {
+                QObject *o = d->children.at(i);
+                if (o && o != modalWidget && o->isWidgetType()) {
+                    QWidget *w  = static_cast<QWidget *>(o);
+                    // do not forward the event to child windows; QApplication does this for us
+                    if (!w->isWindow())
+                        QApplication::sendEvent(w, event);
                 }
             }
+        }
 #if defined(Q_WS_WIN)
             setDisabledStyle(this, (event->type() == QEvent::WindowBlocked));
 #endif
-        }
         break;
 #ifndef QT_NO_TOOLTIP
     case QEvent::ToolTip: