diff options
author | Eike Rathke <erack@openoffice.org> | 2011-01-15 22:08:33 +0100 |
---|---|---|
committer | Eike Rathke <erack@openoffice.org> | 2011-01-15 22:08:33 +0100 |
commit | 94e7f1d15d1e9eefadbfe8e5912fee0ebccba0ca (patch) | |
tree | 30fb2e7013fd5b6ab6818a0720a2eeb310a0718d /unotools | |
parent | bfc17d4b7e7462dc228d683b2d6b1ba5ebcaa3d2 (diff) |
locales34: #i116429# ensure shutdown of the CachedTextSearch global before the things it needs in its dtor are destructed; patch from <cmc>
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/inc/unotools/textsearch.hxx | 9 | ||||
-rw-r--r-- | unotools/source/i18n/textsearch.cxx | 37 |
2 files changed, 23 insertions, 23 deletions
diff --git a/unotools/inc/unotools/textsearch.hxx b/unotools/inc/unotools/textsearch.hxx index e4cd095fcc14..800bf025d5a9 100644 --- a/unotools/inc/unotools/textsearch.hxx +++ b/unotools/inc/unotools/textsearch.hxx @@ -127,15 +127,6 @@ public: class UNOTOOLS_DLLPUBLIC TextSearch { - struct CachedTextSearch - { - ::osl::Mutex mutex; - ::com::sun::star::util::SearchOptions Options; - ::com::sun::star::uno::Reference< ::com::sun::star::util::XTextSearch > xTextSearch; - }; - - static CachedTextSearch maCache; - static ::com::sun::star::uno::Reference< ::com::sun::star::util::XTextSearch > getXTextSearch( const ::com::sun::star::util::SearchOptions& rPara ); diff --git a/unotools/source/i18n/textsearch.cxx b/unotools/source/i18n/textsearch.cxx index 3f722adb0dba..1254ddc983d8 100644 --- a/unotools/source/i18n/textsearch.cxx +++ b/unotools/source/i18n/textsearch.cxx @@ -40,6 +40,7 @@ #include <unotools/charclass.hxx> #include <comphelper/processfactory.hxx> #include <unotools/textsearch.hxx> +#include <rtl/instance.hxx> using namespace ::com::sun::star::util; using namespace ::com::sun::star::uno; @@ -90,13 +91,6 @@ SearchParam::SearchParam( const SearchParam& rParam ) nTransliterationFlags = rParam.nTransliterationFlags; } -// Klasse zum Suchen eines Strings in einem Text. Es wird genau nach -// dem String gesucht. -// ( Die Unterscheidung der Gross/Klein-Schreibung kann mit einen Flag -// unterdrueckt werden ) - -TextSearch::CachedTextSearch TextSearch::maCache; - static bool lcl_Equals( const SearchOptions& rSO1, const SearchOptions& rSO2 ) { return rSO1.algorithmType == rSO2.algorithmType && @@ -112,27 +106,42 @@ static bool lcl_Equals( const SearchOptions& rSO1, const SearchOptions& rSO2 ) rSO1.transliterateFlags == rSO2.transliterateFlags; } +namespace +{ + struct CachedTextSearch + { + ::osl::Mutex mutex; + ::com::sun::star::util::SearchOptions Options; + ::com::sun::star::uno::Reference< ::com::sun::star::util::XTextSearch > xTextSearch; + }; + + struct theCachedTextSearch + : public rtl::Static< CachedTextSearch, theCachedTextSearch > {}; +} + Reference<XTextSearch> TextSearch::getXTextSearch( const SearchOptions& rPara ) { - osl::MutexGuard aGuard(maCache.mutex); + CachedTextSearch &rCache = theCachedTextSearch::get(); + + osl::MutexGuard aGuard(rCache.mutex); - if ( lcl_Equals(maCache.Options, rPara) ) - return maCache.xTextSearch; + if ( lcl_Equals(rCache.Options, rPara) ) + return rCache.xTextSearch; try { Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); - maCache.xTextSearch.set( xMSF->createInstance( + rCache.xTextSearch.set( xMSF->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.TextSearch" ) ) ), UNO_QUERY_THROW ); - maCache.xTextSearch->setOptions( rPara ); - maCache.Options = rPara; + rCache.xTextSearch->setOptions( rPara ); + rCache.Options = rPara; } catch ( Exception& ) { DBG_ERRORFILE( "TextSearch ctor: Exception caught!" ); } - return maCache.xTextSearch; + return rCache.xTextSearch; } TextSearch::TextSearch(const SearchParam & rParam, LanguageType eLang ) |