Accessibility: Menu item should keep track of owner being valid

The QAction may stay around while the parent/owner gets deleted.
This is for example the case for some dynamically created menus.

This is required for fixing QTBUG-30792

Change-Id: I7b6122edec6def69aed77502403134e1568e21c9
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
This commit is contained in:
Frederik Gladhorn 2013-04-22 15:51:05 +02:00 committed by The Qt Project
parent 8d60a10462
commit a7ce34dba4
2 changed files with 3 additions and 2 deletions

View File

@ -206,7 +206,7 @@ int QAccessibleMenuItem::indexOfChild(const QAccessibleInterface * child) const
bool QAccessibleMenuItem::isValid() const
{
return m_action ? true : false;
return m_action && m_owner ? true : false;
}
QAccessibleInterface *QAccessibleMenuItem::parent() const

View File

@ -43,6 +43,7 @@
#define QACCESSIBLEMENU_H
#include <QtWidgets/private/qaccessiblewidget_p.h>
#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE
@ -120,7 +121,7 @@ protected:
QAction *action() const;
private:
QAction *m_action;
QWidget *m_owner; // can hold either QMenu or the QMenuBar that contains the action
QPointer<QWidget> m_owner; // can hold either QMenu or the QMenuBar that contains the action
};
#endif // QT_NO_MENU