From 3f5470899ceaab7283a12ba4bc0761ca931b71b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Tue, 17 May 2011 21:05:15 +0100 Subject: [PATCH] return by reference instead of pointer --- sfx2/source/appl/sfxpicklist.cxx | 16 ++++++++-------- sfx2/source/inc/sfxpicklist.hxx | 4 ++-- sfx2/source/menu/virtmenu.cxx | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sfx2/source/appl/sfxpicklist.cxx b/sfx2/source/appl/sfxpicklist.cxx index 9da29d1a7b69..16cbd6f25818 100644 --- a/sfx2/source/appl/sfxpicklist.cxx +++ b/sfx2/source/appl/sfxpicklist.cxx @@ -170,7 +170,7 @@ SfxPickList::PickListEntry* SfxPickList::GetPickListEntry( sal_uInt32 nIndex ) return 0; } -SfxPickList* SfxPickList::GetOrCreate( const sal_uInt32 nMenuSize ) +SfxPickList& SfxPickList::GetOrCreate( const sal_uInt32 nMenuSize ) { if ( !pUniqueInstance ) { @@ -179,13 +179,13 @@ SfxPickList* SfxPickList::GetOrCreate( const sal_uInt32 nMenuSize ) pUniqueInstance = new SfxPickList( nMenuSize ); } - return pUniqueInstance; + return *pUniqueInstance; } -SfxPickList* SfxPickList::Get() +SfxPickList& SfxPickList::Get() { ::osl::MutexGuard aGuard( thePickListMutex::get() ); - return pUniqueInstance; + return *pUniqueInstance; } void SfxPickList::Delete() @@ -258,10 +258,10 @@ void SfxPickList::CreatePickListEntries() void SfxPickList::CreateMenuEntries( Menu* pMenu ) { - static sal_Bool bPickListMenuInitializing = sal_False; - ::osl::MutexGuard aGuard( thePickListMutex::get() ); + static sal_Bool bPickListMenuInitializing = sal_False; + if ( bPickListMenuInitializing ) // method is not reentrant! return; @@ -295,7 +295,7 @@ void SfxPickList::ExecuteEntry( sal_uInt32 nIndex ) { ::osl::ClearableMutexGuard aGuard( thePickListMutex::get() ); - PickListEntry *pPick = SfxPickList::Get()->GetPickListEntry( nIndex ); + PickListEntry *pPick = SfxPickList::Get().GetPickListEntry( nIndex ); if ( pPick ) { @@ -327,7 +327,7 @@ void SfxPickList::ExecuteMenuEntry( sal_uInt16 nId ) String SfxPickList::GetMenuEntryTitle( sal_uInt32 nIndex ) { - PickListEntry *pPick = SfxPickList::Get()->GetPickListEntry( nIndex ); + PickListEntry *pPick = SfxPickList::Get().GetPickListEntry( nIndex ); if ( pPick ) return pPick->aTitle; diff --git a/sfx2/source/inc/sfxpicklist.hxx b/sfx2/source/inc/sfxpicklist.hxx index 9de953b9d889..9a6723ad6b75 100644 --- a/sfx2/source/inc/sfxpicklist.hxx +++ b/sfx2/source/inc/sfxpicklist.hxx @@ -67,8 +67,8 @@ class SfxPickList : public SfxListener void RemovePickListEntries(); public: - static SfxPickList* GetOrCreate( const sal_uInt32 nMenuSize ); - static SfxPickList* Get(); + static SfxPickList& GetOrCreate( const sal_uInt32 nMenuSize ); + static SfxPickList& Get(); static void Delete(); sal_uInt32 GetAllowedMenuSize() { return m_nAllowedMenuSize; } diff --git a/sfx2/source/menu/virtmenu.cxx b/sfx2/source/menu/virtmenu.cxx index fa8a09161ea7..e427b052b2b4 100644 --- a/sfx2/source/menu/virtmenu.cxx +++ b/sfx2/source/menu/virtmenu.cxx @@ -899,7 +899,7 @@ IMPL_LINK( SfxVirtualMenu, Activate, Menu *, pMenu ) // ggf. Pick-Menu erzeugen if ( pParent && pSVMenu == pParent->pPickMenu ) { - SfxPickList::Get()->CreateMenuEntries( pParent->pPickMenu ); + SfxPickList::Get().CreateMenuEntries( pParent->pPickMenu ); } else pPickMenu = pSVMenu->GetPopupMenu(SID_PICKLIST); @@ -1068,7 +1068,7 @@ IMPL_LINK( SfxVirtualMenu, Select, Menu *, pMenu ) } else if ( nSlotId >= START_ITEMID_PICKLIST && nSlotId <= END_ITEMID_PICKLIST ) { - SfxPickList::Get()->ExecuteMenuEntry( nSlotId ); + SfxPickList::Get().ExecuteMenuEntry( nSlotId ); return sal_True; }