summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/widgets/kernel/qapplication.cpp8
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp11
2 files changed, 10 insertions, 9 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index b7d0869289..abd0231b00 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -3320,12 +3320,10 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
QWidget* w = static_cast<QWidget *>(receiver);
QWheelEvent* wheel = static_cast<QWheelEvent*>(e);
- // QTBUG-40656, combo and other popups should close when the main window gets a wheel event.
- while (QWidget *popup = QApplication::activePopupWidget()) {
+ // QTBUG-40656, QTBUG-42731: ignore wheel events when a popup (QComboBox) is open.
+ if (const QWidget *popup = QApplication::activePopupWidget()) {
if (w->window() != popup)
- popup->close();
- else
- break;
+ return true;
}
QPoint relpos = wheel->pos();
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index ac32ee4968..23d0ffd2d2 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -124,7 +124,7 @@ private slots:
void pixmapIcon();
void mouseWheel_data();
void mouseWheel();
- void wheelClosingPopup();
+ void popupWheelHandling();
void layoutDirection();
void itemListPosition();
void separatorItem_data();
@@ -2037,9 +2037,9 @@ void tst_QComboBox::mouseWheel()
}
}
-void tst_QComboBox::wheelClosingPopup()
+void tst_QComboBox::popupWheelHandling()
{
- // QTBUG-40656, combo and other popups should close when the main window gets a wheel event.
+ // QTBUG-40656, QTBUG-42731 combo and other popups should not be affected by wheel events.
QScrollArea scrollArea;
scrollArea.move(300, 300);
QWidget *widget = new QWidget;
@@ -2058,9 +2058,12 @@ void tst_QComboBox::wheelClosingPopup()
QVERIFY(QTest::qWaitForWindowExposed(&scrollArea));
comboBox->showPopup();
QTRY_VERIFY(comboBox->view() && comboBox->view()->isVisible());
+ const QPoint popupPos = comboBox->view()->pos();
QWheelEvent event(QPointF(10, 10), WHEEL_DELTA, Qt::NoButton, Qt::NoModifier);
QVERIFY(QCoreApplication::sendEvent(scrollArea.windowHandle(), &event));
- QTRY_VERIFY(!comboBox->view()->isVisible());
+ QCoreApplication::processEvents();
+ QVERIFY(comboBox->view()->isVisible());
+ QCOMPARE(comboBox->view()->pos(), popupPos);
}
void tst_QComboBox::layoutDirection()