Fix possible crash issue when testing the state of a QAccessibleMenuItem

The owner widget of a QAccessibleMenuItem may be NULL. Checking for a valid pointer before dereferncing.

Port of Qt 4 patch.

Change-Id: Ic3149ccc5d6ae0ebc83dae58163ae2f60397fd28
(cherry picked from commit 3f526366af14f6c640dd52cd089b00776ab06731)
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
bb10
Yan Shapochnik 2012-04-11 15:02:49 -04:00 committed by Qt by Nokia
parent 40a1e8eccf
commit dae4bd8489
1 changed files with 2 additions and 2 deletions

View File

@ -249,7 +249,7 @@ QAccessible::State QAccessibleMenuItem::state() const
QAccessible::State s;
QWidget *own = owner();
if (own->testAttribute(Qt::WA_WState_Visible) == false || m_action->isVisible() == false) {
if (own && own->testAttribute(Qt::WA_WState_Visible) == false || m_action->isVisible() == false) {
s.invisible = true;
}
@ -262,7 +262,7 @@ QAccessible::State QAccessibleMenuItem::state() const
s.focused = true;
#endif
}
if (own->style()->styleHint(QStyle::SH_Menu_MouseTracking))
if (own && own->style()->styleHint(QStyle::SH_Menu_MouseTracking))
s.hotTracked = true;
if (m_action->isSeparator() || !m_action->isEnabled())
s.disabled = true;