basctl/source/basicide/basicmod.hxx | 2 include/sfx2/module.hxx | 7 +- sc/source/ui/app/scmod.cxx | 2 sd/source/ui/app/sdmod.cxx | 2 sfx2/source/appl/module.cxx | 105 +++++++++++++++++++++++++----------- starmath/source/smmod.cxx | 2 sw/source/uibase/app/swmodule.cxx | 2 7 files changed, 84 insertions(+), 38 deletions(-)
New commits: commit abde31a2bc68302e1afafe1fcc3f5d85369010f8 Author: Noel Grandin <n...@peralex.com> Date: Mon Jun 6 10:16:23 2016 +0200 Revert "Simplify sfx2 removing SfxModuleArr_Impl and dummy SfxModule flag" This reverts commit e319ef1171dab61fff2201f5c1470ca09894c395. Apparently, at some point, someone added a 'bool bDummy' param to SfxModule, but only updated 2 of the 5 callsites. Since we're passing in pointers here, at the other call sites, the bDummy param evaluated to 'true'. diff --git a/basctl/source/basicide/basicmod.hxx b/basctl/source/basicide/basicmod.hxx index b52a1c7..f462927 100644 --- a/basctl/source/basicide/basicmod.hxx +++ b/basctl/source/basicide/basicmod.hxx @@ -31,7 +31,7 @@ class Module : public SfxModule static Module* mpModule; public: Module ( ResMgr *pMgr, SfxObjectFactory *pObjFact) : - SfxModule( pMgr, pObjFact, nullptr ) + SfxModule( pMgr, false, pObjFact, nullptr ) { } public: static Module*& Get () { return mpModule; } diff --git a/include/sfx2/module.hxx b/include/sfx2/module.hxx index 7871675..6e10d7c 100644 --- a/include/sfx2/module.hxx +++ b/include/sfx2/module.hxx @@ -35,6 +35,7 @@ class SfxObjectFactory; class ModalDialog; class SfxObjectFactory; class SfxModule; +class SfxModuleArr_Impl; class SfxModule_Impl; class SfxSlotPool; struct SfxChildWinContextFactory; @@ -53,6 +54,7 @@ class SFX2_DLLPUBLIC SfxModule : public SfxShell { private: ResMgr* pResMgr; + bool bDummy : 1; SfxModule_Impl* pImpl; SAL_DLLPRIVATE void Construct_Impl(); @@ -66,7 +68,8 @@ private: public: - SfxModule( ResMgr* pMgrP, SfxObjectFactory* pFactoryP, ... ); + SfxModule( ResMgr* pMgrP, bool bDummy, + SfxObjectFactory* pFactoryP, ... ); virtual ~SfxModule(); ResMgr* GetResMgr(); @@ -93,7 +96,7 @@ public: static FieldUnit GetModuleFieldUnit( css::uno::Reference< css::frame::XFrame > const & i_frame ); FieldUnit GetFieldUnit() const; - SAL_DLLPRIVATE static std::vector<SfxModule*>& GetModules_Impl(); + SAL_DLLPRIVATE static SfxModuleArr_Impl& GetModules_Impl(); SAL_DLLPRIVATE static void DestroyModules_Impl(); SAL_DLLPRIVATE SfxTbxCtrlFactArr_Impl* GetTbxCtrlFactories_Impl() const; SAL_DLLPRIVATE SfxStbCtrlFactArr_Impl* GetStbCtrlFactories_Impl() const; diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index c45480f..359fb23 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -130,7 +130,7 @@ void ScModule::InitInterface_Impl() } ScModule::ScModule( SfxObjectFactory* pFact ) : - SfxModule( ResMgr::CreateResMgr( "sc" ), pFact, nullptr ), + SfxModule( ResMgr::CreateResMgr( "sc" ), false, pFact, nullptr ), aIdleTimer("sc ScModule IdleTimer"), aSpellIdle("sc ScModule SpellIdle"), mpDragData(new ScDragData), diff --git a/sd/source/ui/app/sdmod.cxx b/sd/source/ui/app/sdmod.cxx index 9b54068..59f62db 100644 --- a/sd/source/ui/app/sdmod.cxx +++ b/sd/source/ui/app/sdmod.cxx @@ -67,7 +67,7 @@ void SdModule::InitInterface_Impl() // Ctor SdModule::SdModule(SfxObjectFactory* pFact1, SfxObjectFactory* pFact2 ) -: SfxModule( ResMgr::CreateResMgr("sd"), +: SfxModule( ResMgr::CreateResMgr("sd"), false, pFact1, pFact2, nullptr ), pTransferClip(nullptr), pTransferDrag(nullptr), diff --git a/sfx2/source/appl/module.cxx b/sfx2/source/appl/module.cxx index bb1730d..2cedda8 100644 --- a/sfx2/source/appl/module.cxx +++ b/sfx2/source/appl/module.cxx @@ -42,7 +42,41 @@ #include "childwinimpl.hxx" #include <ctrlfactoryimpl.hxx> -static std::vector<SfxModule*>* pModules=nullptr; +class SfxModuleArr_Impl +{ + typedef ::std::vector<SfxModule*> DataType; + DataType maData; +public: + + typedef DataType::iterator iterator; + + iterator begin() + { + return maData.begin(); + } + + void erase( const iterator& it ) + { + maData.erase(it); + } + + SfxModule* operator[] ( size_t i ) + { + return maData[i]; + } + + void push_back( SfxModule* p ) + { + maData.push_back(p); + } + + size_t size() const + { + return maData.size(); + } +}; + +static SfxModuleArr_Impl* pModules=nullptr; class SfxModule_Impl { @@ -102,8 +136,9 @@ ResMgr* SfxModule::GetResMgr() return pResMgr; } -SfxModule::SfxModule( ResMgr* pMgrP, SfxObjectFactory* pFactoryP, ... ) - : pResMgr( pMgrP ), pImpl(nullptr) +SfxModule::SfxModule( ResMgr* pMgrP, bool bDummyP, + SfxObjectFactory* pFactoryP, ... ) + : pResMgr( pMgrP ), bDummy( bDummyP ), pImpl(nullptr) { Construct_Impl(); va_list pVarArgs; @@ -116,42 +151,49 @@ SfxModule::SfxModule( ResMgr* pMgrP, SfxObjectFactory* pFactoryP, ... ) void SfxModule::Construct_Impl() { - SfxApplication *pApp = SfxGetpApp(); - std::vector<SfxModule*> &rArr = GetModules_Impl(); - rArr.push_back( this ); - pImpl = new SfxModule_Impl; - pImpl->pSlotPool = new SfxSlotPool(&pApp->GetAppSlotPool_Impl()); - - pImpl->pTbxCtrlFac=nullptr; - pImpl->pStbCtrlFac=nullptr; - pImpl->pFactArr=nullptr; - pImpl->pImgListSmall=nullptr; - pImpl->pImgListBig=nullptr; - - SetPool( &pApp->GetPool() ); + if( !bDummy ) + { + SfxApplication *pApp = SfxGetpApp(); + SfxModuleArr_Impl& rArr = GetModules_Impl(); + SfxModule* pPtr = this; + rArr.push_back( pPtr ); + pImpl = new SfxModule_Impl; + pImpl->pSlotPool = new SfxSlotPool(&pApp->GetAppSlotPool_Impl()); + + pImpl->pTbxCtrlFac=nullptr; + pImpl->pStbCtrlFac=nullptr; + pImpl->pFactArr=nullptr; + pImpl->pImgListSmall=nullptr; + pImpl->pImgListBig=nullptr; + + SetPool( &pApp->GetPool() ); + } } SfxModule::~SfxModule() { - if ( SfxGetpApp()->Get_Impl() ) + if( !bDummy ) { - // The module will be destroyed before the Deinitialize, - // so remove from the array - std::vector<SfxModule*>& rArr = GetModules_Impl(); - for( sal_uInt16 nPos = rArr.size(); nPos--; ) + if ( SfxGetpApp()->Get_Impl() ) { - if( rArr[ nPos ] == this ) + // The module will be destroyed before the Deinitialize, + // so remove from the array + SfxModuleArr_Impl& rArr = GetModules_Impl(); + for( sal_uInt16 nPos = rArr.size(); nPos--; ) { - rArr.erase( rArr.begin() + nPos ); - break; + if( rArr[ nPos ] == this ) + { + rArr.erase( rArr.begin() + nPos ); + break; + } } + + delete pImpl; } + delete pResMgr; } - - delete pImpl; - delete pResMgr; } @@ -250,10 +292,10 @@ VclPtr<SfxTabPage> SfxModule::CreateTabPage( sal_uInt16, vcl::Window*, const Sfx return VclPtr<SfxTabPage>(); } -std::vector<SfxModule*>& SfxModule::GetModules_Impl() +SfxModuleArr_Impl& SfxModule::GetModules_Impl() { if( !pModules ) - pModules = new std::vector<SfxModule*>; + pModules = new SfxModuleArr_Impl; return *pModules; }; @@ -261,9 +303,10 @@ void SfxModule::DestroyModules_Impl() { if ( pModules ) { - for( sal_uInt16 nPos = pModules->size(); nPos--; ) + SfxModuleArr_Impl& rModules = *pModules; + for( sal_uInt16 nPos = rModules.size(); nPos--; ) { - SfxModule* pMod = (*pModules)[nPos]; + SfxModule* pMod = rModules[nPos]; delete pMod; } delete pModules; diff --git a/starmath/source/smmod.cxx b/starmath/source/smmod.cxx index 02a4526..1d8fa98 100644 --- a/starmath/source/smmod.cxx +++ b/starmath/source/smmod.cxx @@ -159,7 +159,7 @@ void SmModule::InitInterface_Impl() } SmModule::SmModule(SfxObjectFactory* pObjFact) : - SfxModule(ResMgr::CreateResMgr("sm"), pObjFact, nullptr) + SfxModule(ResMgr::CreateResMgr("sm"), false, pObjFact, nullptr) { SetName("StarMath"); diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx index 3ab2832..eae1553 100644 --- a/sw/source/uibase/app/swmodule.cxx +++ b/sw/source/uibase/app/swmodule.cxx @@ -140,7 +140,7 @@ using namespace ::com::sun::star::uno; SwModule::SwModule( SfxObjectFactory* pWebFact, SfxObjectFactory* pFact, SfxObjectFactory* pGlobalFact ) - : SfxModule( ResMgr::CreateResMgr( "sw" ), pWebFact, + : SfxModule( ResMgr::CreateResMgr( "sw" ), false, pWebFact, pFact, pGlobalFact, nullptr ), m_pModuleConfig(nullptr), m_pUsrPref(nullptr), _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits