From 832b1a48050df80515353d9887976f364913ff8e Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 21 May 2010 14:10:53 +0200 Subject: Fixed an assert in QMenu The code was changed and changed the behaviour. This is basically a kind of revert. Reviewed-By: gabi Task-Number: QTBUG-10735 --- tests/auto/qmenu/tst_qmenu.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'tests') diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index 9dc18e0f3f..63e7310d3e 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -104,6 +105,7 @@ private slots: void setFixedWidth(); void deleteActionInTriggered(); void pushButtonPopulateOnAboutToShow(); + void QTBUG_10735_crashWithDialog(); protected slots: void onActivated(QAction*); void onHighlighted(QAction*); @@ -932,5 +934,57 @@ void tst_QMenu::pushButtonPopulateOnAboutToShow() } +class MyMenu : public QMenu +{ + Q_OBJECT +public: + MyMenu() : m_currentIndex(0) + { + for (int i = 0; i < 2; ++i) + dialogActions[i] = addAction( QString("dialog %1").arg(i), dialogs + i, SLOT(exec())); + } + + + void activateAction(int index) + { + m_currentIndex = index; + popup(QPoint()); + QTest::qWaitForWindowShown(this); + setActiveAction(dialogActions[index]); + QTimer::singleShot(500, this, SLOT(checkVisibility())); + QTest::keyClick(this, Qt::Key_Enter); //activation + } + +public slots: + void activateLastAction() + { + activateAction(1); + } + + void checkVisibility() + { + QTRY_VERIFY(dialogs[m_currentIndex].isVisible()); + if (m_currentIndex == 1) { + QApplication::closeAllWindows(); //this is the end of the test + } + } + + +private: + QAction *dialogActions[2]; + QDialog dialogs[2]; + int m_currentIndex; +}; + +void tst_QMenu::QTBUG_10735_crashWithDialog() +{ + MyMenu menu; + + QTimer::singleShot(1000, &menu, SLOT(activateLastAction())); + menu.activateAction(0); + +} + + QTEST_MAIN(tst_QMenu) #include "tst_qmenu.moc" -- cgit v1.2.3