use StaticWithArg

This commit is contained in:
Caolán McNamara 2011-05-30 15:30:27 +01:00
parent 205540afc1
commit 5a3c6e0a3d
3 changed files with 14 additions and 18 deletions

View file

@ -57,6 +57,7 @@
#include "rtl/textenc.h"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
#include "rtl/instance.hxx"
#include "sal/types.h"
#include "salhelper/simplereferenceobject.hxx"
@ -150,9 +151,6 @@ bool canRemoveFromLayer(int layer, rtl::Reference< Node > const & node) {
}
}
static bool singletonCreated = false;
static Components * singleton = 0;
}
class Components::WriteThread:
@ -217,23 +215,19 @@ void Components::WriteThread::run() {
reference_->clear();
}
class theComponentsSingleton :
public rtl::StaticWithArg<
Components,
css::uno::Reference< css::uno::XComponentContext >,
theComponentsSingleton>
{
};
Components & Components::getSingleton(
css::uno::Reference< css::uno::XComponentContext > const & context)
{
OSL_ASSERT(context.is());
if (!singletonCreated) {
static Components theSingleton(context);
singleton = &theSingleton;
singletonCreated = true;
}
if (singleton == 0) {
throw css::uno::RuntimeException(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"configmgr no Components singleton")),
css::uno::Reference< css::uno::XInterface >());
}
return *singleton;
return theComponentsSingleton::get(context);
}
bool Components::allLocales(rtl::OUString const & locale) {

View file

@ -123,12 +123,13 @@ private:
typedef void FileParser(
rtl::OUString const &, int, Data &, Partial const *, Modifications *,
Additions *);
public:
Components(
com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
const & context);
~Components();
private:
void parseFileLeniently(
FileParser * parseFile, rtl::OUString const & url, int layer,

View file

@ -130,7 +130,8 @@ bool RootAccess::isUpdate() const {
return update_;
}
RootAccess::~RootAccess() {
RootAccess::~RootAccess()
{
osl::MutexGuard g(*lock_);
getComponents().removeRootAccess(this);
}