[Libreoffice-commits] .: 2 commits - binfilter/bf_sfx2 binfilter/bf_svtools
Caolán McNamara
caolan at kemper.freedesktop.org
Thu May 26 05:51:36 PDT 2011
binfilter/bf_sfx2/source/appl/sfx2_appbas.cxx | 95 ++++++++++++--------
binfilter/bf_svtools/source/config/svt_lingucfg.cxx | 1
2 files changed, 57 insertions(+), 39 deletions(-)
New commits:
commit 822ea5e9f38b385f042da95e8255723a07c0fe49
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu May 26 13:24:15 2011 +0100
don't leak configitems
diff --git a/binfilter/bf_sfx2/source/appl/sfx2_appbas.cxx b/binfilter/bf_sfx2/source/appl/sfx2_appbas.cxx
index c688a4d..4310f77 100644
--- a/binfilter/bf_sfx2/source/appl/sfx2_appbas.cxx
+++ b/binfilter/bf_sfx2/source/appl/sfx2_appbas.cxx
@@ -54,6 +54,7 @@
#include <legacysmgr/legacy_binfilters_smgr.hxx>
#include "bf_so3/staticbaseurl.hxx"
+#include <boost/scoped_ptr.hpp>
namespace binfilter {
@@ -65,31 +66,21 @@ using namespace ::com::sun::star::script;
namespace
{
- static BasicManager*& lcl_getAppBasicManager()
+ class AppBasicManagerHolder
{
- static BasicManager* s_pAppBasicManager = NULL;
- return s_pAppBasicManager;
- }
-}
-
-//========================================================================
-
-StarBASIC* SfxApplication::GetBasic_Impl() const
-{
- BasicManager* pBasMgr = lcl_getAppBasicManager();
- return pBasMgr ? pBasMgr->GetLib(0) : NULL;
-}
-
-//=========================================================================
-
-BasicManager* SfxApplication::GetBasicManager()
-{
- if ( pAppData_Impl->nBasicCallLevel == 0 )
- // sicherheitshalber
- EnterBasicCall();
-
- BasicManager*& pBasMgr = lcl_getAppBasicManager();
- if ( !pBasMgr )
+ private:
+ SfxScriptLibraryContainer* m_pBasicCont;
+ SfxDialogLibraryContainer* m_pDialogCont;
+ BasicManager* m_pAppBasicManager;
+ public:
+ AppBasicManagerHolder();
+ BasicManager* getBasicManager() { return m_pAppBasicManager; };
+ ~AppBasicManagerHolder();
+ };
+
+ boost::scoped_ptr<AppBasicManagerHolder> s_pAppBasicManager;
+
+ AppBasicManagerHolder::AppBasicManagerHolder()
{
// Directory bestimmen
SvtPathOptions aPathCFG;
@@ -105,41 +96,69 @@ BasicManager* SfxApplication::GetBasicManager()
INetURLObject aAppBasic( SvtPathOptions().SubstituteVariable( String::CreateFromAscii("$(progurl)") ) );
aAppBasic.insertName( Application::GetAppName() );
- pBasMgr = new BasicManager( new StarBASIC, &aAppBasicDir );
+ m_pAppBasicManager = new BasicManager(new StarBASIC, &aAppBasicDir);
// Als Destination das erste Dir im Pfad:
String aFileName( aAppBasic.getName() );
aAppBasic = INetURLObject( aAppBasicDir.GetToken(1) );
DBG_ASSERT( aAppBasic.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" );
aAppBasic.insertName( aFileName );
- pBasMgr->SetStorageName( aAppBasic.PathToFileName() );
+ m_pAppBasicManager->SetStorageName( aAppBasic.PathToFileName() );
// globale Variablen
- StarBASIC *pBas = pBasMgr->GetLib(0);
+ StarBASIC *pBas = m_pAppBasicManager->GetLib(0);
sal_Bool bBasicWasModified = pBas->IsModified();
// Basic container
- SfxScriptLibraryContainer* pBasicCont = new SfxScriptLibraryContainer
- ( DEFINE_CONST_UNICODE( "StarBasic" ), pBasMgr );
- pBasicCont->acquire(); // Hold via UNO
- Reference< XLibraryContainer > xBasicCont = static_cast< XLibraryContainer* >( pBasicCont );
- pBasicCont->setBasicManager( pBasMgr );
+ m_pBasicCont = new SfxScriptLibraryContainer
+ ( DEFINE_CONST_UNICODE( "StarBasic" ), m_pAppBasicManager );
+ m_pBasicCont->acquire(); // Hold via UNO
+ Reference< XLibraryContainer > xBasicCont = static_cast< XLibraryContainer* >( m_pBasicCont );
+ m_pBasicCont->setBasicManager( m_pAppBasicManager );
// Dialog container
- SfxDialogLibraryContainer* pDialogCont = new SfxDialogLibraryContainer( NULL );
- pDialogCont->acquire(); // Hold via UNO
- Reference< XLibraryContainer > xDialogCont = static_cast< XLibraryContainer* >( pDialogCont );
+ m_pDialogCont = new SfxDialogLibraryContainer( NULL );
+ m_pDialogCont->acquire(); // Hold via UNO
+ Reference< XLibraryContainer > xDialogCont = static_cast< XLibraryContainer* >( m_pDialogCont );
LibraryContainerInfo* pInfo = new LibraryContainerInfo
- ( xBasicCont, xDialogCont, static_cast< OldBasicPassword* >( pBasicCont ) );
- pBasMgr->SetLibraryContainerInfo( pInfo );
+ ( xBasicCont, xDialogCont, static_cast< OldBasicPassword* >( m_pBasicCont ) );
+ m_pAppBasicManager->SetLibraryContainerInfo( pInfo );
// Durch MakeVariable wird das Basic modifiziert.
if ( !bBasicWasModified )
pBas->SetModified( sal_False );
}
- return pBasMgr;
+ AppBasicManagerHolder::~AppBasicManagerHolder()
+ {
+ m_pDialogCont->release();
+ m_pBasicCont->release();
+ BasicManager::LegacyDeleteBasicManager(m_pAppBasicManager);
+ }
+}
+
+//========================================================================
+
+StarBASIC* SfxApplication::GetBasic_Impl() const
+{
+ if (!s_pAppBasicManager)
+ return NULL;
+ return s_pAppBasicManager->getBasicManager()->GetLib(0);
+}
+
+//=========================================================================
+
+BasicManager* SfxApplication::GetBasicManager()
+{
+ if ( pAppData_Impl->nBasicCallLevel == 0 )
+ // sicherheitshalber
+ EnterBasicCall();
+
+ if (!s_pAppBasicManager)
+ s_pAppBasicManager.reset(new AppBasicManagerHolder);
+
+ return s_pAppBasicManager->getBasicManager();
}
//--------------------------------------------------------------------
commit 5c3c4b0fc3a72acb17a89e3133c462d97d1f79c6
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu May 26 12:06:59 2011 +0100
incorrect ref bump
diff --git a/binfilter/bf_svtools/source/config/svt_lingucfg.cxx b/binfilter/bf_svtools/source/config/svt_lingucfg.cxx
index 26bc95b..6565860 100644
--- a/binfilter/bf_svtools/source/config/svt_lingucfg.cxx
+++ b/binfilter/bf_svtools/source/config/svt_lingucfg.cxx
@@ -535,7 +535,6 @@ SvtLinguConfigItem & SvtLinguConfig::GetConfigItem()
pCfgItem = new SvtLinguConfigItem;
ItemHolder1::holdConfigItem(E_LINGUCFG);
}
- ++nCfgItemRefCount;
return *pCfgItem;
}
More information about the Libreoffice-commits
mailing list