From b9e3f5955154073ddb87b181f77aa46ae05269df Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 3 Sep 2014 14:50:27 +0200 Subject: [PATCH] QMdiSubWindow: Keep event filter on system menu over its lifetime. QMdiSubWindow::eventFilter() is supposed to close the sub window on a double click on the menu icon. However, it did not receive the double click event since it removed itself when the menu was hidden, which happened before the double click was delivered. Task-number: QTBUG-25179 Change-Id: I5e7fb02dda26ceab12e8b7554fc604066a0a3136 Reviewed-by: Shawn Rutledge --- src/widgets/widgets/qmdisubwindow.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index 5521d866b2..5166c3cf38 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -1043,6 +1043,7 @@ void QMdiSubWindowPrivate::createSystemMenu() Q_ASSERT_X(q, "QMdiSubWindowPrivate::createSystemMenu", "You can NOT call this function before QMdiSubWindow's ctor"); systemMenu = new QMenu(q); + systemMenu->installEventFilter(q); const QStyle *style = q->style(); addToSystemMenu(RestoreAction, QMdiSubWindow::tr("&Restore"), SLOT(showNormal())); actions[RestoreAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarNormalButton, 0, q)); @@ -2569,7 +2570,6 @@ void QMdiSubWindow::showSystemMenu() // Adjust x() with -menuwidth in reverse mode. if (isRightToLeft()) globalPopupPos -= QPoint(d->systemMenu->sizeHint().width(), 0); - d->systemMenu->installEventFilter(this); d->systemMenu->popup(globalPopupPos); } #endif // QT_NO_MENU @@ -2702,7 +2702,6 @@ bool QMdiSubWindow::eventFilter(QObject *object, QEvent *event) QMouseEvent *mouseEvent = static_cast(event); d->hoveredSubControl = d->getSubControl(mapFromGlobal(mouseEvent->globalPos())); } else if (event->type() == QEvent::Hide) { - d->systemMenu->removeEventFilter(this); d->activeSubControl = QStyle::SC_None; update(QRegion(0, 0, width(), d->titleBarHeight())); }