diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-02-04 14:02:41 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-02-04 16:34:53 +0000 |
commit | 4904180247c0d5745a393e3cd57eaae29f3837e5 (patch) | |
tree | dcdc86ab3f80de6bed1a8d57fe3786084be625f3 /vcl | |
parent | 0c3505f01a792449b0c6bf81f518e7a062eea146 (diff) |
fix leak from framework::AddonMenuManager::BuildMenu
provide a callback when a menu item gets deleted
Change-Id: I5b5f1a181fb10f53f6b1fe7b5637d385e1517530
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/window/menu.cxx | 11 | ||||
-rw-r--r-- | vcl/source/window/menuitemlist.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/menuitemlist.hxx | 5 |
3 files changed, 14 insertions, 4 deletions
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 078e1bb31ec9..d08c48a98f4e 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -758,11 +758,16 @@ MenuItemBits Menu::GetItemBits( sal_uInt16 nItemId ) const return nBits; } -void Menu::SetUserValue( sal_uInt16 nItemId, sal_uLong nValue ) +void Menu::SetUserValue(sal_uInt16 nItemId, sal_uLong nValue, MenuUserDataReleaseFunction aFunc) { - MenuItemData* pData = pItemList->GetData( nItemId ); - if ( pData ) + MenuItemData* pData = pItemList->GetData(nItemId); + if (pData) + { + if (pData->aUserValueReleaseFunc) + pData->aUserValueReleaseFunc(pData->nUserValue); + pData->aUserValueReleaseFunc = aFunc; pData->nUserValue = nValue; + } } sal_uLong Menu::GetUserValue( sal_uInt16 nItemId ) const diff --git a/vcl/source/window/menuitemlist.cxx b/vcl/source/window/menuitemlist.cxx index d6b680adf6dd..c104ba8a1ef8 100644 --- a/vcl/source/window/menuitemlist.cxx +++ b/vcl/source/window/menuitemlist.cxx @@ -32,6 +32,8 @@ using namespace vcl; MenuItemData::~MenuItemData() { + if (aUserValueReleaseFunc) + aUserValueReleaseFunc(nUserValue); if( pAutoSubMenu ) { static_cast<PopupMenu*>(pAutoSubMenu)->pRefAutoSubMenu = NULL; diff --git a/vcl/source/window/menuitemlist.hxx b/vcl/source/window/menuitemlist.hxx index 619e3eb89f00..699ece3e646c 100644 --- a/vcl/source/window/menuitemlist.hxx +++ b/vcl/source/window/menuitemlist.hxx @@ -42,7 +42,8 @@ struct MenuItemData OUString aHelpCommandStr; // Help command string (to reference external help) OString sIdent; OString aHelpId; // Help-Id - sal_uLong nUserValue; // User value + sal_uLong nUserValue; // User value + MenuUserDataReleaseFunction aUserValueReleaseFunc; // called when MenuItemData is destroyed Image aImage; // Image vcl::KeyCode aAccelKey; // Accelerator-Key bool bChecked; // Checked @@ -64,6 +65,7 @@ struct MenuItemData , pSubMenu(NULL) , pAutoSubMenu(NULL) , nUserValue(0) + , aUserValueReleaseFunc(0) , bChecked(false) , bEnabled(false) , bVisible(false) @@ -81,6 +83,7 @@ struct MenuItemData , pAutoSubMenu(NULL) , aText(rStr) , nUserValue(0) + , aUserValueReleaseFunc(0) , aImage(rImage) , bChecked(false) , bEnabled(false) |