diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2016-10-30 14:34:18 +0200 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2016-10-30 15:50:31 +0200 |
commit | 94876fe2704cb5107234ad76c86122ac9d95f866 (patch) | |
tree | d55701606099ce3db9f3b051166a4ba33fb58e7f /svtools | |
parent | 99da628e17e873a5fa2f726e7a1732b21c3d4b33 (diff) |
Let Menu dispose submenus
(I'm not sure about how good are the changes from ScopedVclPtr
to non-scoped, and disposeAndClear to clear. They aren't really
needed, because of the VclReferenceBase::mbDisposed logic. But
at least they should be safe, as long as we have disposeOnce
calls in Menu's dtor.)
See also previous commits:
4433d95b374c13a3501cdf3a6e273f68eb49873a
("MenuItemData now properly disposes the submenu")
89c23b4aaef931b5d6009efaf44ce6e6c976e8d4
("Sub menus no longer need manual disposing")
Change-Id: I9d455a94590f5eec9b097947f6984f1b3e477b52
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/control/calendar.cxx | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/svtools/source/control/calendar.cxx b/svtools/source/control/calendar.cxx index d51b05f4fff3..9865781c1a6c 100644 --- a/svtools/source/control/calendar.cxx +++ b/svtools/source/control/calendar.cxx @@ -1155,7 +1155,6 @@ void Calendar::ImplShowMenu( const Point& rPos, const Date& rDate ) Date aOldFirstDate = GetFirstMonth(); ScopedVclPtrInstance<PopupMenu> aPopupMenu; - VclPtr<PopupMenu> pYearPopupMenus[MENU_YEAR_COUNT]; sal_uInt16 nMonthOff; sal_uInt16 nCurItemId; sal_uInt16 nYear = rDate.GetYear()-1; @@ -1172,13 +1171,13 @@ void Calendar::ImplShowMenu( const Point& rPos, const Date& rDate ) // construct menu (include years with different months) for ( i = 0; i < MENU_YEAR_COUNT; i++ ) { - pYearPopupMenus[i] = VclPtr<PopupMenu>::Create(); + VclPtrInstance<PopupMenu> pYearPopupMenu; for ( j = 1; j <= 12; j++ ) - pYearPopupMenus[i]->InsertItem( nYearIdCount+j, + pYearPopupMenu->InsertItem( nYearIdCount+j, maCalendarWrapper.getDisplayName( i18n::CalendarDisplayIndex::MONTH, j-1, 1)); aPopupMenu->InsertItem( 10+i, OUString::number( nYear+i ) ); - aPopupMenu->SetPopupMenu( 10+i, pYearPopupMenus[i] ); + aPopupMenu->SetPopupMenu( 10+i, pYearPopupMenu ); nYearIdCount += 1000; } @@ -1186,14 +1185,6 @@ void Calendar::ImplShowMenu( const Point& rPos, const Date& rDate ) nCurItemId = aPopupMenu->Execute( this, rPos ); mbMenuDown = false; - // destroy menu - aPopupMenu->SetPopupMenu( 2, nullptr ); - for ( i = 0; i < MENU_YEAR_COUNT; i++ ) - { - aPopupMenu->SetPopupMenu( 10+i, nullptr ); - pYearPopupMenus[i].disposeAndClear(); - } - if ( nCurItemId ) { sal_uInt16 nTempMonthOff = nMonthOff % 12; |