summaryrefslogtreecommitdiff
path: root/basctl/source/basicide/iderdll.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-08-24 10:04:16 +0100
committerCaolán McNamara <caolanm@redhat.com>2011-08-24 11:21:43 +0100
commit8d2d9ce5f4323ec2542acf57f52a26d5826bcc3b (patch)
tree7fbbb8ee8c130d3b36cb56b8e0d2dab148d46282 /basctl/source/basicide/iderdll.cxx
parent1b5ee6c7f47b56a5ca52a327bcb2712a1d8a77a1 (diff)
rearrange this to not leak search configitem
Diffstat (limited to 'basctl/source/basicide/iderdll.cxx')
-rw-r--r--basctl/source/basicide/iderdll.cxx51
1 files changed, 33 insertions, 18 deletions
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 )