QDBusPlatformMenu and Item: remove stored pointers when deleted

Prevents memory leak and later access of dangling pointers.

Change-Id: I6a1da1ec191ad5fa880c5884c37fd5582215e825
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
bb10
Shawn Rutledge 2015-08-20 17:12:14 +02:00 committed by Olivier Goffart (Woboq GmbH)
parent 21e1354d42
commit b39c9011db
2 changed files with 7 additions and 0 deletions

View File

@ -59,6 +59,11 @@ QDBusPlatformMenuItem::QDBusPlatformMenuItem(quintptr tag)
menuItemsByID.insert(m_dbusID, this);
}
QDBusPlatformMenuItem::~QDBusPlatformMenuItem()
{
menuItemsByID.remove(m_dbusID);
}
void QDBusPlatformMenuItem::setTag(quintptr tag)
{
m_tag = tag;
@ -155,6 +160,7 @@ QDBusPlatformMenu::QDBusPlatformMenu(quintptr tag)
QDBusPlatformMenu::~QDBusPlatformMenu()
{
menusByID.remove(m_dbusID);
m_topLevelMenus.removeOne(this);
}
void QDBusPlatformMenu::insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before)

View File

@ -57,6 +57,7 @@ class QDBusPlatformMenuItem : public QPlatformMenuItem
public:
QDBusPlatformMenuItem(quintptr tag = 0LL);
~QDBusPlatformMenuItem();
quintptr tag()const Q_DECL_OVERRIDE { return m_tag; }
void setTag(quintptr tag) Q_DECL_OVERRIDE;