Make QToolButtonPrivate::popupTimerDone() more robust
Avoid dereferencing the q-pointer if the button has been destructed meanwhile popup was open. Task-number: QTBUG-26956 Change-Id: I68190e9fe84c669229ae0ce4d573ee7a02a8a141 Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com> Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
This commit is contained in:
parent
be51772d02
commit
4d6cb199b8
@ -778,15 +778,16 @@ void QToolButtonPrivate::popupTimerDone()
|
|||||||
actualMenu->d_func()->causedPopup.action = defaultAction;
|
actualMenu->d_func()->causedPopup.action = defaultAction;
|
||||||
actionsCopy = q->actions(); //(the list of action may be modified in slots)
|
actionsCopy = q->actions(); //(the list of action may be modified in slots)
|
||||||
actualMenu->exec(p);
|
actualMenu->exec(p);
|
||||||
|
|
||||||
|
if (!that)
|
||||||
|
return;
|
||||||
|
|
||||||
QObject::disconnect(actualMenu, SIGNAL(aboutToHide()), q, SLOT(_q_updateButtonDown()));
|
QObject::disconnect(actualMenu, SIGNAL(aboutToHide()), q, SLOT(_q_updateButtonDown()));
|
||||||
if (mustDeleteActualMenu)
|
if (mustDeleteActualMenu)
|
||||||
delete actualMenu;
|
delete actualMenu;
|
||||||
else
|
else
|
||||||
QObject::disconnect(actualMenu, SIGNAL(triggered(QAction*)), q, SLOT(_q_menuTriggered(QAction*)));
|
QObject::disconnect(actualMenu, SIGNAL(triggered(QAction*)), q, SLOT(_q_menuTriggered(QAction*)));
|
||||||
|
|
||||||
if (!that)
|
|
||||||
return;
|
|
||||||
|
|
||||||
actionsCopy.clear();
|
actionsCopy.clear();
|
||||||
|
|
||||||
if (repeat)
|
if (repeat)
|
||||||
|
@ -63,6 +63,7 @@ private slots:
|
|||||||
void collapseTextOnPriority();
|
void collapseTextOnPriority();
|
||||||
void task230994_iconSize();
|
void task230994_iconSize();
|
||||||
void task176137_autoRepeatOfAction();
|
void task176137_autoRepeatOfAction();
|
||||||
|
void qtbug_26956_popupTimerDone();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void sendMouseClick();
|
void sendMouseClick();
|
||||||
@ -223,5 +224,14 @@ void tst_QToolButton::sendMouseClick()
|
|||||||
QTest::mouseClick(w, Qt::LeftButton, 0, QPoint(7,7));
|
QTest::mouseClick(w, Qt::LeftButton, 0, QPoint(7,7));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QToolButton::qtbug_26956_popupTimerDone()
|
||||||
|
{
|
||||||
|
QToolButton *tb = new QToolButton;
|
||||||
|
tb->setMenu(new QMenu(tb));
|
||||||
|
tb->menu()->addAction("Qt");
|
||||||
|
tb->deleteLater();
|
||||||
|
tb->showMenu();
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QToolButton)
|
QTEST_MAIN(tst_QToolButton)
|
||||||
#include "tst_qtoolbutton.moc"
|
#include "tst_qtoolbutton.moc"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user