Kaydet (Commit) abde31a2 authored tarafından Noel Grandin's avatar Noel Grandin

Revert "Simplify sfx2 removing SfxModuleArr_Impl and dummy SfxModule flag"

This reverts commit e319ef11.

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'.
üst 9f0ed9d8
...@@ -31,7 +31,7 @@ class Module : public SfxModule ...@@ -31,7 +31,7 @@ class Module : public SfxModule
static Module* mpModule; static Module* mpModule;
public: public:
Module ( ResMgr *pMgr, SfxObjectFactory *pObjFact) : Module ( ResMgr *pMgr, SfxObjectFactory *pObjFact) :
SfxModule( pMgr, pObjFact, nullptr ) SfxModule( pMgr, false, pObjFact, nullptr )
{ } { }
public: public:
static Module*& Get () { return mpModule; } static Module*& Get () { return mpModule; }
......
...@@ -35,6 +35,7 @@ class SfxObjectFactory; ...@@ -35,6 +35,7 @@ class SfxObjectFactory;
class ModalDialog; class ModalDialog;
class SfxObjectFactory; class SfxObjectFactory;
class SfxModule; class SfxModule;
class SfxModuleArr_Impl;
class SfxModule_Impl; class SfxModule_Impl;
class SfxSlotPool; class SfxSlotPool;
struct SfxChildWinContextFactory; struct SfxChildWinContextFactory;
...@@ -53,6 +54,7 @@ class SFX2_DLLPUBLIC SfxModule : public SfxShell ...@@ -53,6 +54,7 @@ class SFX2_DLLPUBLIC SfxModule : public SfxShell
{ {
private: private:
ResMgr* pResMgr; ResMgr* pResMgr;
bool bDummy : 1;
SfxModule_Impl* pImpl; SfxModule_Impl* pImpl;
SAL_DLLPRIVATE void Construct_Impl(); SAL_DLLPRIVATE void Construct_Impl();
...@@ -66,7 +68,8 @@ private: ...@@ -66,7 +68,8 @@ private:
public: public:
SfxModule( ResMgr* pMgrP, SfxObjectFactory* pFactoryP, ... ); SfxModule( ResMgr* pMgrP, bool bDummy,
SfxObjectFactory* pFactoryP, ... );
virtual ~SfxModule(); virtual ~SfxModule();
ResMgr* GetResMgr(); ResMgr* GetResMgr();
...@@ -93,7 +96,7 @@ public: ...@@ -93,7 +96,7 @@ public:
static FieldUnit GetModuleFieldUnit( css::uno::Reference< css::frame::XFrame > const & i_frame ); static FieldUnit GetModuleFieldUnit( css::uno::Reference< css::frame::XFrame > const & i_frame );
FieldUnit GetFieldUnit() const; 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 static void DestroyModules_Impl();
SAL_DLLPRIVATE SfxTbxCtrlFactArr_Impl* GetTbxCtrlFactories_Impl() const; SAL_DLLPRIVATE SfxTbxCtrlFactArr_Impl* GetTbxCtrlFactories_Impl() const;
SAL_DLLPRIVATE SfxStbCtrlFactArr_Impl* GetStbCtrlFactories_Impl() const; SAL_DLLPRIVATE SfxStbCtrlFactArr_Impl* GetStbCtrlFactories_Impl() const;
......
...@@ -130,7 +130,7 @@ void ScModule::InitInterface_Impl() ...@@ -130,7 +130,7 @@ void ScModule::InitInterface_Impl()
} }
ScModule::ScModule( SfxObjectFactory* pFact ) : ScModule::ScModule( SfxObjectFactory* pFact ) :
SfxModule( ResMgr::CreateResMgr( "sc" ), pFact, nullptr ), SfxModule( ResMgr::CreateResMgr( "sc" ), false, pFact, nullptr ),
aIdleTimer("sc ScModule IdleTimer"), aIdleTimer("sc ScModule IdleTimer"),
aSpellIdle("sc ScModule SpellIdle"), aSpellIdle("sc ScModule SpellIdle"),
mpDragData(new ScDragData), mpDragData(new ScDragData),
......
...@@ -67,7 +67,7 @@ void SdModule::InitInterface_Impl() ...@@ -67,7 +67,7 @@ void SdModule::InitInterface_Impl()
// Ctor // Ctor
SdModule::SdModule(SfxObjectFactory* pFact1, SfxObjectFactory* pFact2 ) SdModule::SdModule(SfxObjectFactory* pFact1, SfxObjectFactory* pFact2 )
: SfxModule( ResMgr::CreateResMgr("sd"), : SfxModule( ResMgr::CreateResMgr("sd"), false,
pFact1, pFact2, nullptr ), pFact1, pFact2, nullptr ),
pTransferClip(nullptr), pTransferClip(nullptr),
pTransferDrag(nullptr), pTransferDrag(nullptr),
......
...@@ -42,7 +42,41 @@ ...@@ -42,7 +42,41 @@
#include "childwinimpl.hxx" #include "childwinimpl.hxx"
#include <ctrlfactoryimpl.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 class SfxModule_Impl
{ {
...@@ -102,8 +136,9 @@ ResMgr* SfxModule::GetResMgr() ...@@ -102,8 +136,9 @@ ResMgr* SfxModule::GetResMgr()
return pResMgr; return pResMgr;
} }
SfxModule::SfxModule( ResMgr* pMgrP, SfxObjectFactory* pFactoryP, ... ) SfxModule::SfxModule( ResMgr* pMgrP, bool bDummyP,
: pResMgr( pMgrP ), pImpl(nullptr) SfxObjectFactory* pFactoryP, ... )
: pResMgr( pMgrP ), bDummy( bDummyP ), pImpl(nullptr)
{ {
Construct_Impl(); Construct_Impl();
va_list pVarArgs; va_list pVarArgs;
...@@ -116,42 +151,49 @@ SfxModule::SfxModule( ResMgr* pMgrP, SfxObjectFactory* pFactoryP, ... ) ...@@ -116,42 +151,49 @@ SfxModule::SfxModule( ResMgr* pMgrP, SfxObjectFactory* pFactoryP, ... )
void SfxModule::Construct_Impl() void SfxModule::Construct_Impl()
{ {
SfxApplication *pApp = SfxGetpApp(); if( !bDummy )
std::vector<SfxModule*> &rArr = GetModules_Impl(); {
rArr.push_back( this ); SfxApplication *pApp = SfxGetpApp();
pImpl = new SfxModule_Impl; SfxModuleArr_Impl& rArr = GetModules_Impl();
pImpl->pSlotPool = new SfxSlotPool(&pApp->GetAppSlotPool_Impl()); SfxModule* pPtr = this;
rArr.push_back( pPtr );
pImpl->pTbxCtrlFac=nullptr; pImpl = new SfxModule_Impl;
pImpl->pStbCtrlFac=nullptr; pImpl->pSlotPool = new SfxSlotPool(&pApp->GetAppSlotPool_Impl());
pImpl->pFactArr=nullptr;
pImpl->pImgListSmall=nullptr; pImpl->pTbxCtrlFac=nullptr;
pImpl->pImgListBig=nullptr; pImpl->pStbCtrlFac=nullptr;
pImpl->pFactArr=nullptr;
SetPool( &pApp->GetPool() ); pImpl->pImgListSmall=nullptr;
pImpl->pImgListBig=nullptr;
SetPool( &pApp->GetPool() );
}
} }
SfxModule::~SfxModule() SfxModule::~SfxModule()
{ {
if ( SfxGetpApp()->Get_Impl() ) if( !bDummy )
{ {
// The module will be destroyed before the Deinitialize, if ( SfxGetpApp()->Get_Impl() )
// so remove from the array
std::vector<SfxModule*>& rArr = GetModules_Impl();
for( sal_uInt16 nPos = rArr.size(); nPos--; )
{ {
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 ); if( rArr[ nPos ] == this )
break; {
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 ...@@ -250,10 +292,10 @@ VclPtr<SfxTabPage> SfxModule::CreateTabPage( sal_uInt16, vcl::Window*, const Sfx
return VclPtr<SfxTabPage>(); return VclPtr<SfxTabPage>();
} }
std::vector<SfxModule*>& SfxModule::GetModules_Impl() SfxModuleArr_Impl& SfxModule::GetModules_Impl()
{ {
if( !pModules ) if( !pModules )
pModules = new std::vector<SfxModule*>; pModules = new SfxModuleArr_Impl;
return *pModules; return *pModules;
}; };
...@@ -261,9 +303,10 @@ void SfxModule::DestroyModules_Impl() ...@@ -261,9 +303,10 @@ void SfxModule::DestroyModules_Impl()
{ {
if ( pModules ) 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 pMod;
} }
delete pModules; delete pModules;
......
...@@ -159,7 +159,7 @@ void SmModule::InitInterface_Impl() ...@@ -159,7 +159,7 @@ void SmModule::InitInterface_Impl()
} }
SmModule::SmModule(SfxObjectFactory* pObjFact) : SmModule::SmModule(SfxObjectFactory* pObjFact) :
SfxModule(ResMgr::CreateResMgr("sm"), pObjFact, nullptr) SfxModule(ResMgr::CreateResMgr("sm"), false, pObjFact, nullptr)
{ {
SetName("StarMath"); SetName("StarMath");
......
...@@ -140,7 +140,7 @@ using namespace ::com::sun::star::uno; ...@@ -140,7 +140,7 @@ using namespace ::com::sun::star::uno;
SwModule::SwModule( SfxObjectFactory* pWebFact, SwModule::SwModule( SfxObjectFactory* pWebFact,
SfxObjectFactory* pFact, SfxObjectFactory* pFact,
SfxObjectFactory* pGlobalFact ) SfxObjectFactory* pGlobalFact )
: SfxModule( ResMgr::CreateResMgr( "sw" ), pWebFact, : SfxModule( ResMgr::CreateResMgr( "sw" ), false, pWebFact,
pFact, pGlobalFact, nullptr ), pFact, pGlobalFact, nullptr ),
m_pModuleConfig(nullptr), m_pModuleConfig(nullptr),
m_pUsrPref(nullptr), m_pUsrPref(nullptr),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment