summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-06-06 13:25:46 +0200
committerNoel Grandin <noel@peralex.com>2016-06-06 15:31:41 +0200
commitdfa8ecef62f4f55aa614013a80ad9aeb61a4fdac (patch)
treeb6910678c51b6aba2796cf6af324aa9e44e574ce /sfx2
parent55a07417c8df1f451cac33d5dfc6a2ef450fa544 (diff)
Revert "Revert "Simplify sfx2 removing SfxModuleArr_Impl and dummy SfxModule flag""
This reverts commit abde31a2bc68302e1afafe1fcc3f5d85369010f8. Since my analysis was completely incorrect, and the bug was elsewhere.
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/appl/module.cxx105
1 files changed, 31 insertions, 74 deletions
diff --git a/sfx2/source/appl/module.cxx b/sfx2/source/appl/module.cxx
index 2cedda83662c..bb1730dedcde 100644
--- a/sfx2/source/appl/module.cxx
+++ b/sfx2/source/appl/module.cxx
@@ -42,41 +42,7 @@
#include "childwinimpl.hxx"
#include <ctrlfactoryimpl.hxx>
-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;
+static std::vector<SfxModule*>* pModules=nullptr;
class SfxModule_Impl
{
@@ -136,9 +102,8 @@ ResMgr* SfxModule::GetResMgr()
return pResMgr;
}
-SfxModule::SfxModule( ResMgr* pMgrP, bool bDummyP,
- SfxObjectFactory* pFactoryP, ... )
- : pResMgr( pMgrP ), bDummy( bDummyP ), pImpl(nullptr)
+SfxModule::SfxModule( ResMgr* pMgrP, SfxObjectFactory* pFactoryP, ... )
+ : pResMgr( pMgrP ), pImpl(nullptr)
{
Construct_Impl();
va_list pVarArgs;
@@ -151,49 +116,42 @@ SfxModule::SfxModule( ResMgr* pMgrP, bool bDummyP,
void SfxModule::Construct_Impl()
{
- 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() );
- }
+ 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() );
}
SfxModule::~SfxModule()
{
- if( !bDummy )
+ if ( SfxGetpApp()->Get_Impl() )
{
- if ( SfxGetpApp()->Get_Impl() )
+ // 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--; )
{
- // 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--; )
+ if( rArr[ nPos ] == this )
{
- if( rArr[ nPos ] == this )
- {
- rArr.erase( rArr.begin() + nPos );
- break;
- }
+ rArr.erase( rArr.begin() + nPos );
+ break;
}
-
- delete pImpl;
}
- delete pResMgr;
}
+
+ delete pImpl;
+ delete pResMgr;
}
@@ -292,10 +250,10 @@ VclPtr<SfxTabPage> SfxModule::CreateTabPage( sal_uInt16, vcl::Window*, const Sfx
return VclPtr<SfxTabPage>();
}
-SfxModuleArr_Impl& SfxModule::GetModules_Impl()
+std::vector<SfxModule*>& SfxModule::GetModules_Impl()
{
if( !pModules )
- pModules = new SfxModuleArr_Impl;
+ pModules = new std::vector<SfxModule*>;
return *pModules;
};
@@ -303,10 +261,9 @@ void SfxModule::DestroyModules_Impl()
{
if ( pModules )
{
- SfxModuleArr_Impl& rModules = *pModules;
- for( sal_uInt16 nPos = rModules.size(); nPos--; )
+ for( sal_uInt16 nPos = pModules->size(); nPos--; )
{
- SfxModule* pMod = rModules[nPos];
+ SfxModule* pMod = (*pModules)[nPos];
delete pMod;
}
delete pModules;