diff options
Diffstat (limited to 'basctl')
-rw-r--r-- | basctl/inc/iderdll.hxx | 6 | ||||
-rw-r--r-- | basctl/source/basicide/basobj2.cxx | 4 | ||||
-rw-r--r-- | basctl/source/basicide/basobj3.cxx | 2 | ||||
-rw-r--r-- | basctl/source/basicide/iderdll.cxx | 51 | ||||
-rw-r--r-- | basctl/source/basicide/unomodel.cxx | 2 |
5 files changed, 42 insertions, 23 deletions
diff --git a/basctl/inc/iderdll.hxx b/basctl/inc/iderdll.hxx index 02e2c75bb014..2b89991e5ff7 100644 --- a/basctl/inc/iderdll.hxx +++ b/basctl/inc/iderdll.hxx @@ -29,6 +29,11 @@ #ifndef _IDERDLL_HXX #define _IDERDLL_HXX +namespace BasicIDEGlobals +{ + void ensure(); +} + class BasicIDEShell; class BasicIDEData; @@ -45,7 +50,6 @@ public: BasicIDEShell* GetShell() const { return pShell; } BasicIDEData* GetExtraData(); - static void Init(); static BasicIDEDLL* GetDLL(); }; diff --git a/basctl/source/basicide/basobj2.cxx b/basctl/source/basicide/basobj2.cxx index c14f7688ff58..ef79e588912a 100644 --- a/basctl/source/basicide/basobj2.cxx +++ b/basctl/source/basicide/basobj2.cxx @@ -86,7 +86,7 @@ namespace BasicIDE void Organize( sal_Int16 tabId ) { - BasicIDEDLL::Init(); + BasicIDEGlobals::ensure(); BasicEntryDescriptor aDesc; BasicIDEShell* pIDEShell = IDE_DLL()->GetShell(); @@ -274,7 +274,7 @@ namespace { (void)rMacroDesc; - BasicIDEDLL::Init(); + BasicIDEGlobals::ensure(); IDE_DLL()->GetExtraData()->ChoosingMacro() = sal_True; diff --git a/basctl/source/basicide/basobj3.cxx b/basctl/source/basicide/basobj3.cxx index 398e927a738c..c0760134833b 100644 --- a/basctl/source/basicide/basobj3.cxx +++ b/basctl/source/basicide/basobj3.cxx @@ -425,7 +425,7 @@ void InvalidateDebuggerSlots() long HandleBasicError( StarBASIC* pBasic ) { - BasicIDEDLL::Init(); + BasicIDEGlobals::ensure(); BasicIDE::BasicStopped(); // no error output during macro choosing diff --git a/basctl/source/basicide/iderdll.cxx b/basctl/source/basicide/iderdll.cxx index db1f3cd90770..6de1ba98b82f 100644 --- a/basctl/source/basicide/iderdll.cxx +++ b/basctl/source/basicide/iderdll.cxx @@ -28,7 +28,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_basctl.hxx" - + +#include <comphelper/scoped_disposing_ptr.hxx> +#include <comphelper/processfactory.hxx> #include <ide_pch.hxx> @@ -61,39 +63,51 @@ using ::rtl::OUString; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; +namespace +{ + //Holds a BasicIDEDLL and release it on exit, or dispose of the + //default XComponent, whichever comes first + class BasicIDEDLLInstance : public comphelper::scoped_disposing_solar_mutex_reset_ptr<BasicIDEDLL> + { + public: + BasicIDEDLLInstance() : comphelper::scoped_disposing_solar_mutex_reset_ptr<BasicIDEDLL>(::com::sun::star::uno::Reference<com::sun::star::lang::XComponent>(comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop"))), ::com::sun::star::uno::UNO_QUERY_THROW), new BasicIDEDLL) + { + } + }; -static BasicIDEDLL* pBasicIDEDLL = 0; + struct theBasicIDEDLLInstance : public rtl::Static<BasicIDEDLLInstance, theBasicIDEDLLInstance> {}; +} -BasicIDEDLL* BasicIDEDLL::GetDLL() +namespace BasicIDEGlobals { - return pBasicIDEDLL; + void ensure() + { + theBasicIDEDLLInstance::get(); + } } -IDEResId::IDEResId( sal_uInt16 nId ): - ResId( nId, *(*(BasicIDEModule**)GetAppData(SHL_IDE))->GetResMgr() ) +BasicIDEDLL* BasicIDEDLL::GetDLL() { + return theBasicIDEDLLInstance::get().get(); } -BasicIDEDLL::BasicIDEDLL() +IDEResId::IDEResId( sal_uInt16 nId ): + ResId( nId, *(*(BasicIDEModule**)GetAppData(SHL_IDE))->GetResMgr() ) { - pBasicIDEDLL = this; - pShell = 0; - pExtraData = 0; - - GetExtraData(); // to cause GlobalErrorHdl to be set } BasicIDEDLL::~BasicIDEDLL() { delete pExtraData; +#if 0 *(BasicIDEDLL**)GetAppData(SHL_IDE) = NULL; +#endif } -void BasicIDEDLL::Init() +BasicIDEDLL::BasicIDEDLL() + : pShell(0) + , pExtraData(0) { - if ( pBasicIDEDLL ) - return; - SfxObjectFactory* pFact = &BasicDocShell::Factory(); (void)pFact; @@ -102,7 +116,8 @@ void BasicIDEDLL::Init() BASIC_MOD() = new BasicIDEModule( pMgr, &BasicDocShell::Factory() ); - new BasicIDEDLL; + GetExtraData(); // to cause GlobalErrorHdl to be set + SfxModule* pMod = BASIC_MOD(); SfxObjectFactory& rFactory = BasicDocShell::Factory(); @@ -119,7 +134,7 @@ BasicIDEData* BasicIDEDLL::GetExtraData() { if ( !pExtraData ) pExtraData = new BasicIDEData; - return pExtraData; + return pExtraData; } BasicIDEData::BasicIDEData() : aObjCatPos( INVPOSITION, INVPOSITION ) diff --git a/basctl/source/basicide/unomodel.cxx b/basctl/source/basicide/unomodel.cxx index 76b3057b6409..3e599136dd0e 100644 --- a/basctl/source/basicide/unomodel.cxx +++ b/basctl/source/basicide/unomodel.cxx @@ -121,7 +121,7 @@ uno::Reference< uno::XInterface > SAL_CALL SIDEModel_createInstance( const uno::Reference< lang::XMultiServiceFactory > & ) throw( uno::Exception ) { SolarMutexGuard aGuard; - BasicIDEDLL::Init(); + BasicIDEGlobals::ensure(); SfxObjectShell* pShell = new BasicDocShell(); return uno::Reference< uno::XInterface >( pShell->GetModel() ); } |