summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-06-20 15:56:35 +0200
committerNoel Grandin <noelgrandin@gmail.com>2016-06-23 06:28:00 +0000
commitaa0d0536a444fb26d9e570bd6bf6c1bdc3596cf3 (patch)
tree8b2a5207e77fa4054a37b33c25378c23a00af8ed /sc/source
parentb722f3d6fc72877e8caaaae7291d5d736ddc494d (diff)
tdf#97527 - vcl: reference-count Menu
some places are marked with "dodgy"- need to check those to see what is going on, because they are leaving dangling pointers behind in the Menu class Change-Id: I41d5c7c0fec2f70ce9e3ffdc48cd03d26c0a869b Reviewed-on: https://gerrit.libreoffice.org/26516 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/ui/dbgui/csvgrid.cxx10
-rw-r--r--sc/source/ui/inc/csvgrid.hxx2
-rw-r--r--sc/source/ui/inc/tphfedit.hxx4
-rw-r--r--sc/source/ui/miscdlgs/acredlin.cxx16
-rw-r--r--sc/source/ui/navipi/content.cxx38
-rw-r--r--sc/source/ui/navipi/navipi.cxx8
-rw-r--r--sc/source/ui/navipi/scenwnd.cxx8
-rw-r--r--sc/source/ui/pagedlg/tphfedit.cxx11
-rw-r--r--sc/source/ui/view/tabcont.cxx8
9 files changed, 59 insertions, 46 deletions
diff --git a/sc/source/ui/dbgui/csvgrid.cxx b/sc/source/ui/dbgui/csvgrid.cxx
index e2a8ec2b75e8..850453b0d671 100644
--- a/sc/source/ui/dbgui/csvgrid.cxx
+++ b/sc/source/ui/dbgui/csvgrid.cxx
@@ -78,7 +78,7 @@ ScCsvGrid::ScCsvGrid( ScCsvControl& rParent ) :
mpEditEngine->SetRefMapMode( MapMode( MAP_PIXEL ) );
maEdEngSize = mpEditEngine->GetPaperSize();
- maPopup.SetMenuFlags( maPopup.GetMenuFlags() | MenuFlags::NoAutoMnemonics );
+ mpPopup->SetMenuFlags( mpPopup->GetMenuFlags() | MenuFlags::NoAutoMnemonics );
EnableRTL( false ); // RTL
InitFonts();
@@ -505,12 +505,12 @@ void ScCsvGrid::SetTypeNames( const std::vector<OUString>& rTypeNames )
maTypeNames = rTypeNames;
Repaint( true );
- maPopup.Clear();
+ mpPopup->Clear();
sal_uInt32 nCount = maTypeNames.size();
sal_uInt32 nIx;
sal_uInt16 nItemId;
for( nIx = 0, nItemId = 1; nIx < nCount; ++nIx, ++nItemId )
- maPopup.InsertItem( nItemId, maTypeNames[ nIx ] );
+ mpPopup->InsertItem( nItemId, maTypeNames[ nIx ] );
::std::for_each( maColStates.begin(), maColStates.end(), Func_SetType( CSV_TYPE_DEFAULT ) );
}
@@ -582,9 +582,9 @@ void ScCsvGrid::ScrollVertRel( ScMoveMode eDir )
void ScCsvGrid::ExecutePopup( const Point& rPos )
{
- sal_uInt16 nItemId = maPopup.Execute( this, rPos );
+ sal_uInt16 nItemId = mpPopup->Execute( this, rPos );
if( nItemId ) // 0 = cancelled
- Execute( CSVCMD_SETCOLUMNTYPE, maPopup.GetItemPos( nItemId ) );
+ Execute( CSVCMD_SETCOLUMNTYPE, mpPopup->GetItemPos( nItemId ) );
}
// selection handling ---------------------------------------------------------
diff --git a/sc/source/ui/inc/csvgrid.hxx b/sc/source/ui/inc/csvgrid.hxx
index 772ef361d9ba..63e20131eef7 100644
--- a/sc/source/ui/inc/csvgrid.hxx
+++ b/sc/source/ui/inc/csvgrid.hxx
@@ -62,7 +62,7 @@ private:
VclPtr<VirtualDevice> mpBackgrDev; /// Grid background, headers, cell texts.
VclPtr<VirtualDevice> mpGridDev; /// Data grid with selection and cursor.
- PopupMenu maPopup; /// Popup menu for column types.
+ VclPtr<PopupMenu> mpPopup; /// Popup menu for column types.
::svtools::ColorConfig* mpColorConfig; /// Application color configuration.
Color maBackColor; /// Cell background color.
diff --git a/sc/source/ui/inc/tphfedit.hxx b/sc/source/ui/inc/tphfedit.hxx
index fcb829f0472e..31c331c7ad17 100644
--- a/sc/source/ui/inc/tphfedit.hxx
+++ b/sc/source/ui/inc/tphfedit.hxx
@@ -104,7 +104,7 @@ class SC_DLLPUBLIC ScExtIButton : public ImageButton
private:
Idle aIdle;
- PopupMenu* pPopupMenu;
+ VclPtr<PopupMenu> pPopupMenu;
Link<ScExtIButton&,void> aMLink;
sal_uInt16 nSelected;
OString aSelectedIdent;
@@ -122,6 +122,8 @@ protected:
public:
ScExtIButton(vcl::Window* pParent, WinBits nBits );
+ virtual ~ScExtIButton();
+ virtual void dispose() override;
void SetPopupMenu(PopupMenu* pPopUp);
diff --git a/sc/source/ui/miscdlgs/acredlin.cxx b/sc/source/ui/miscdlgs/acredlin.cxx
index 407bd39e4003..3121b36ee381 100644
--- a/sc/source/ui/miscdlgs/acredlin.cxx
+++ b/sc/source/ui/miscdlgs/acredlin.cxx
@@ -1676,9 +1676,9 @@ IMPL_LINK_NOARG_TYPED(ScAcceptChgDlg, CommandHdl, SvSimpleTable*, void)
if(aCEvt.GetCommand()==CommandEventId::ContextMenu)
{
- ScPopupMenu aPopup(ScResId(RID_POPUP_CHANGES));
+ ScopedVclPtrInstance<ScPopupMenu> aPopup(ScResId(RID_POPUP_CHANGES));
- aPopup.SetMenuFlags(MenuFlags::HideDisabledEntries);
+ aPopup->SetMenuFlags(MenuFlags::HideDisabledEntries);
SvTreeListEntry* pEntry=pTheView->GetCurEntry();
if(pEntry!=nullptr)
@@ -1687,7 +1687,7 @@ IMPL_LINK_NOARG_TYPED(ScAcceptChgDlg, CommandHdl, SvSimpleTable*, void)
}
else
{
- aPopup.Deactivate();
+ aPopup->Deactivate();
}
sal_uInt16 nSortedCol= pTheView->GetSortedCol();
@@ -1696,15 +1696,15 @@ IMPL_LINK_NOARG_TYPED(ScAcceptChgDlg, CommandHdl, SvSimpleTable*, void)
{
sal_uInt16 nItemId=nSortedCol+SC_SUB_SORT+1;
- aPopup.CheckItem(nItemId);
+ aPopup->CheckItem(nItemId);
- PopupMenu *pSubMenu = aPopup.GetPopupMenu(SC_SUB_SORT);
+ PopupMenu *pSubMenu = aPopup->GetPopupMenu(SC_SUB_SORT);
if (pSubMenu)
pSubMenu->CheckItem(nItemId);
}
- aPopup.EnableItem(SC_CHANGES_COMMENT,false);
+ aPopup->EnableItem(SC_CHANGES_COMMENT,false);
if(pDoc->IsDocEditable() && pEntry!=nullptr)
{
@@ -1714,11 +1714,11 @@ IMPL_LINK_NOARG_TYPED(ScAcceptChgDlg, CommandHdl, SvSimpleTable*, void)
ScChangeAction* pScChangeAction=
static_cast<ScChangeAction*>(pEntryData->pData);
if(pScChangeAction!=nullptr && !pTheView->GetParent(pEntry))
- aPopup.EnableItem(SC_CHANGES_COMMENT);
+ aPopup->EnableItem(SC_CHANGES_COMMENT);
}
}
- sal_uInt16 nCommand=aPopup.Execute( this, GetPointerPosPixel() );
+ sal_uInt16 nCommand = aPopup->Execute( this, GetPointerPosPixel() );
if(nCommand)
{
diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx
index 7e7a04380575..1817750be525 100644
--- a/sc/source/ui/navipi/content.cxx
+++ b/sc/source/ui/navipi/content.cxx
@@ -579,16 +579,16 @@ void ScContentTree::Command( const CommandEvent& rCEvt )
{
// Drag-Drop Modus
- PopupMenu aPop;
- ScPopupMenu aDropMenu( ScResId( RID_POPUP_DROPMODE ) );
- aDropMenu.CheckItem( RID_DROPMODE_URL + pParentWindow->GetDropMode() );
- aPop.InsertItem( 1, pParentWindow->GetStrDragMode() );
- aPop.SetPopupMenu( 1, &aDropMenu );
+ ScopedVclPtrInstance<PopupMenu> aPop;
+ ScopedVclPtrInstance<ScPopupMenu> aDropMenu( ScResId( RID_POPUP_DROPMODE ) );
+ aDropMenu->CheckItem( RID_DROPMODE_URL + pParentWindow->GetDropMode() );
+ aPop->InsertItem( 1, pParentWindow->GetStrDragMode() );
+ aPop->SetPopupMenu( 1, aDropMenu.get() );
// angezeigtes Dokument
- ScPopupMenu aDocMenu;
- aDocMenu.SetMenuFlags( aDocMenu.GetMenuFlags() | MenuFlags::NoAutoMnemonics );
+ ScopedVclPtrInstance<ScPopupMenu> aDocMenu;
+ aDocMenu->SetMenuFlags( aDocMenu->GetMenuFlags() | MenuFlags::NoAutoMnemonics );
sal_uInt16 i=0;
sal_uInt16 nPos=0;
// geladene Dokumente
@@ -604,14 +604,14 @@ void ScContentTree::Command( const CommandEvent& rCEvt )
aEntry += pParentWindow->aStrActive;
else
aEntry += pParentWindow->aStrNotActive;
- aDocMenu.InsertItem( ++i, aEntry );
+ aDocMenu->InsertItem( ++i, aEntry );
if ( !bHiddenDoc && aName == aManualDoc )
nPos = i;
}
pSh = SfxObjectShell::GetNext( *pSh );
}
// "aktives Fenster"
- aDocMenu.InsertItem( ++i, pParentWindow->aStrActiveWin );
+ aDocMenu->InsertItem( ++i, pParentWindow->aStrActiveWin );
if (!bHiddenDoc && aManualDoc.isEmpty())
nPos = i;
// verstecktes Dokument
@@ -619,28 +619,28 @@ void ScContentTree::Command( const CommandEvent& rCEvt )
{
OUString aEntry = aHiddenTitle;
aEntry += pParentWindow->aStrHidden;
- aDocMenu.InsertItem( ++i, aEntry );
+ aDocMenu->InsertItem( ++i, aEntry );
if (bHiddenDoc)
nPos = i;
}
- aDocMenu.CheckItem( nPos );
- aPop.InsertItem( 2, pParentWindow->GetStrDisplay() );
- aPop.SetPopupMenu( 2, &aDocMenu );
+ aDocMenu->CheckItem( nPos );
+ aPop->InsertItem( 2, pParentWindow->GetStrDisplay() );
+ aPop->SetPopupMenu( 2, aDocMenu.get() );
// ausfuehren
- aPop.Execute( this, rCEvt.GetMousePosPixel() );
+ aPop->Execute( this, rCEvt.GetMousePosPixel() );
- if ( aDropMenu.WasHit() ) // Drag-Drop Modus
+ if ( aDropMenu->WasHit() ) // Drag-Drop Modus
{
- sal_uInt16 nId = aDropMenu.GetSelected();
+ sal_uInt16 nId = aDropMenu->GetSelected();
if ( nId >= RID_DROPMODE_URL && nId <= RID_DROPMODE_COPY )
pParentWindow->SetDropMode( nId - RID_DROPMODE_URL );
}
- else if ( aDocMenu.WasHit() ) // angezeigtes Dokument
+ else if ( aDocMenu->WasHit() ) // angezeigtes Dokument
{
- sal_uInt16 nId = aDocMenu.GetSelected();
- OUString aName = aDocMenu.GetItemText(nId);
+ sal_uInt16 nId = aDocMenu->GetSelected();
+ OUString aName = aDocMenu->GetItemText(nId);
SelectDoc( aName );
}
}
diff --git a/sc/source/ui/navipi/navipi.cxx b/sc/source/ui/navipi/navipi.cxx
index 12c81b72e8f8..ba592c67ed2c 100644
--- a/sc/source/ui/navipi/navipi.cxx
+++ b/sc/source/ui/navipi/navipi.cxx
@@ -390,10 +390,10 @@ IMPL_LINK_NOARG_TYPED(CommandToolBox, ToolBoxDropdownClickHdl, ToolBox *, void)
if ( GetCurItemId() == IID_DROPMODE )
{
- ScPopupMenu aPop( ScResId( RID_POPUP_DROPMODE ) );
- aPop.CheckItem( RID_DROPMODE_URL + rDlg.GetDropMode() );
- aPop.Execute( this, GetItemRect(IID_DROPMODE), PopupMenuFlags::ExecuteDown );
- sal_uInt16 nId = aPop.GetSelected();
+ ScopedVclPtrInstance<ScPopupMenu> aPop( ScResId( RID_POPUP_DROPMODE ) );
+ aPop->CheckItem( RID_DROPMODE_URL + rDlg.GetDropMode() );
+ aPop->Execute( this, GetItemRect(IID_DROPMODE), PopupMenuFlags::ExecuteDown );
+ sal_uInt16 nId = aPop->GetSelected();
EndSelection(); // bevore SetDropMode (SetDropMode calls SetItemImage)
diff --git a/sc/source/ui/navipi/scenwnd.cxx b/sc/source/ui/navipi/scenwnd.cxx
index eaa620a2451f..88347cb610c4 100644
--- a/sc/source/ui/navipi/scenwnd.cxx
+++ b/sc/source/ui/navipi/scenwnd.cxx
@@ -135,11 +135,11 @@ bool ScScenarioListBox::Notify( NotifyEvent& rNEvt )
{
if( !pEntry->mbProtected )
{
- ScPopupMenu aPopup( ScResId( RID_POPUP_NAVIPI_SCENARIO ) );
- aPopup.Execute( this, pCEvt->GetMousePosPixel() );
- if (aPopup.WasHit())
+ ScopedVclPtrInstance<ScPopupMenu> aPopup( ScResId( RID_POPUP_NAVIPI_SCENARIO ) );
+ aPopup->Execute( this, pCEvt->GetMousePosPixel() );
+ if (aPopup->WasHit())
{
- switch( aPopup.GetSelected() )
+ switch( aPopup->GetSelected() )
{
case RID_NAVIPI_SCENARIO_DELETE:
DeleteScenario();
diff --git a/sc/source/ui/pagedlg/tphfedit.cxx b/sc/source/ui/pagedlg/tphfedit.cxx
index f9eaeac73e0f..cb6335229a67 100644
--- a/sc/source/ui/pagedlg/tphfedit.cxx
+++ b/sc/source/ui/pagedlg/tphfedit.cxx
@@ -345,6 +345,17 @@ ScExtIButton::ScExtIButton(vcl::Window* pParent, WinBits nBits )
SetDropDown(PushButtonDropdownStyle::Toolbox);
}
+ScExtIButton::~ScExtIButton()
+{
+ disposeOnce();
+}
+
+void ScExtIButton::dispose()
+{
+ pPopupMenu.clear();
+ ImageButton::dispose();
+}
+
VCL_BUILDER_FACTORY_ARGS(ScExtIButton, 0 /* WB_BORDER|WB_TABSTOP */)
void ScExtIButton::SetPopupMenu(PopupMenu* pPopUp)
diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx
index 6fa034c80165..0f7e43015641 100644
--- a/sc/source/ui/view/tabcont.cxx
+++ b/sc/source/ui/view/tabcont.cxx
@@ -86,7 +86,7 @@ ScTabControl::ScTabControl( vcl::Window* pParent, ScViewData* pData )
IMPL_LINK_TYPED(ScTabControl, ShowPageList, const CommandEvent &, rEvent, void)
{
- PopupMenu aPopup;
+ ScopedVclPtrInstance<PopupMenu> aPopup;
sal_uInt16 nCurPageId = GetCurPageId();
@@ -100,14 +100,14 @@ IMPL_LINK_TYPED(ScTabControl, ShowPageList, const CommandEvent &, rEvent, void)
if (pDoc->GetName(i, aString))
{
sal_uInt16 nId = static_cast<sal_uInt16>(i)+1;
- aPopup.InsertItem(nId, aString, MenuItemBits::CHECKABLE);
+ aPopup->InsertItem(nId, aString, MenuItemBits::CHECKABLE);
if (nId == nCurPageId)
- aPopup.CheckItem(nId);
+ aPopup->CheckItem(nId);
}
}
}
- sal_uInt16 nItemId = aPopup.Execute( this, rEvent.GetMousePosPixel() );
+ sal_uInt16 nItemId = aPopup->Execute( this, rEvent.GetMousePosPixel() );
SwitchToPageId(nItemId);
}