diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-05-20 20:52:40 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-05-23 12:31:12 +0100 |
commit | f286daa7298190ba4852ad7e4231d26be60097a2 (patch) | |
tree | ed193415d0129f0926e93511020c93f1c311f7c3 | |
parent | 1151eaf2612c0037d7bbdd5c45a54b0346377f20 (diff) |
convert to non-leaky singleton
-rw-r--r-- | framework/source/uiconfiguration/imagemanagerimpl.cxx | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx index 44de6e21e5..bc5e7414e3 100644 --- a/framework/source/uiconfiguration/imagemanagerimpl.cxx +++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx @@ -61,7 +61,8 @@ #include <vcl/pngread.hxx> #include <vcl/pngwrite.hxx> #include <rtl/logfile.hxx> -#include "svtools/miscopt.hxx" +#include <rtl/instance.hxx> +#include <svtools/miscopt.hxx> using ::rtl::OUString; using ::com::sun::star::uno::Sequence; @@ -105,7 +106,6 @@ static const char* BITMAP_FILE_NAMES[] = namespace framework { static char ModuleImageList[] = "private:resource/images/moduleimages"; - static osl::Mutex* pImageListWrapperMutex = 0; static GlobalImageList* pGlobalImageList = 0; static const char* ImageType_Prefixes[ImageType_COUNT] = { @@ -115,16 +115,15 @@ namespace framework typedef GraphicNameAccess CmdToXGraphicNameAccess; -static osl::Mutex& getGlobalImageListMutex() +namespace { - if ( pImageListWrapperMutex == 0 ) - { - osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; - if ( pImageListWrapperMutex == 0 ) - pImageListWrapperMutex = new osl::Mutex; - } + class theGlobalImageListMutex + : public rtl::Static<osl::Mutex, theGlobalImageListMutex> {}; +} - return *pImageListWrapperMutex; +static osl::Mutex& getGlobalImageListMutex() +{ + return theGlobalImageListMutex::get(); } static GlobalImageList* getGlobalImageList( const uno::Reference< XMultiServiceFactory >& rServiceManager ) |