Fix missing cleanup of native Cocoa menus.
QCocoaMenu was missing a destructor to release various native resources, and this causes issues with pop-up menus when the Qt peers are recycled on successive shows of the same menu. Task-number: QTBUG-27022 Change-Id: I3cdf979804358ce10fe8a87c9e2c90419c6e0b48 Reviewed-by: Christoph Schleifenbaum <christoph.schleifenbaum@kdab.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
parent
823da2d308
commit
d2864ffcc0
@ -59,6 +59,7 @@ class QCocoaMenu : public QPlatformMenu
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QCocoaMenu();
|
QCocoaMenu();
|
||||||
|
~QCocoaMenu();
|
||||||
|
|
||||||
inline virtual void setTag(quintptr tag)
|
inline virtual void setTag(quintptr tag)
|
||||||
{ m_tag = tag; }
|
{ m_tag = tag; }
|
||||||
|
@ -107,6 +107,14 @@ QCocoaMenu::QCocoaMenu() :
|
|||||||
[m_nativeItem setSubmenu:m_nativeMenu];
|
[m_nativeItem setSubmenu:m_nativeMenu];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QCocoaMenu::~QCocoaMenu()
|
||||||
|
{
|
||||||
|
[m_nativeItem setSubmenu:nil];
|
||||||
|
[m_nativeMenu release];
|
||||||
|
[m_delegate release];
|
||||||
|
[m_nativeItem release];
|
||||||
|
}
|
||||||
|
|
||||||
void QCocoaMenu::setText(const QString &text)
|
void QCocoaMenu::setText(const QString &text)
|
||||||
{
|
{
|
||||||
QCocoaAutoReleasePool pool;
|
QCocoaAutoReleasePool pool;
|
||||||
@ -142,6 +150,7 @@ void QCocoaMenu::insertNative(QCocoaMenuItem *item, QCocoaMenuItem *beforeItem)
|
|||||||
if (item->isMerged())
|
if (item->isMerged())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Q_ASSERT([item->nsItem() menu] == NULL);
|
||||||
// if the item we're inserting before is merged, skip along until
|
// if the item we're inserting before is merged, skip along until
|
||||||
// we find a non-merged real item to insert ahead of.
|
// we find a non-merged real item to insert ahead of.
|
||||||
while (beforeItem && beforeItem->isMerged()) {
|
while (beforeItem && beforeItem->isMerged()) {
|
||||||
@ -163,6 +172,7 @@ void QCocoaMenu::removeMenuItem(QPlatformMenuItem *menuItem)
|
|||||||
Q_ASSERT(m_menuItems.contains(cocoaItem));
|
Q_ASSERT(m_menuItems.contains(cocoaItem));
|
||||||
m_menuItems.removeOne(cocoaItem);
|
m_menuItems.removeOne(cocoaItem);
|
||||||
if (!cocoaItem->isMerged()) {
|
if (!cocoaItem->isMerged()) {
|
||||||
|
Q_ASSERT(m_nativeMenu == [cocoaItem->nsItem() menu]);
|
||||||
[m_nativeMenu removeItem: cocoaItem->nsItem()];
|
[m_nativeMenu removeItem: cocoaItem->nsItem()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user