[Libreoffice-commits] core.git: desktop/source i18nlangtag/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Wed Apr 7 18:10:44 UTC 2021


 desktop/source/deployment/gui/dp_gui_dialog2.cxx |   22 ++++++++--------------
 desktop/source/deployment/misc/dp_misc.cxx       |   10 ++++------
 i18nlangtag/source/languagetag/languagetag.cxx   |    5 +++--
 3 files changed, 15 insertions(+), 22 deletions(-)

New commits:
commit 86cadd43f002959d6cfcb7b3e4066076f6d05997
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Apr 6 21:40:28 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Apr 7 20:09:58 2021 +0200

    rtl::Static -> function local static
    
    Change-Id: Iee030633d2e2b020f38797d0d323680fa552b81a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113713
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
index 0d0f609cf013..a3c33f6d639d 100644
--- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx
+++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
@@ -79,19 +79,6 @@ namespace dp_gui {
 #define SHARED_PACKAGE_MANAGER  "shared"
 #define BUNDLED_PACKAGE_MANAGER "bundled"
 
-namespace {
-
-struct StrAllFiles : public rtl::StaticWithInit< OUString, StrAllFiles >
-{
-    OUString operator () () {
-        const SolarMutexGuard guard;
-        std::locale loc = Translate::Create("fps");
-        return Translate::get(STR_FILTERNAME_ALL, loc);
-    }
-};
-
-}
-
 // ExtBoxWithBtns_Impl
 class ExtBoxWithBtns_Impl : public ExtensionBox_Impl
 {
@@ -662,8 +649,15 @@ uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker()
         }
     }
 
+    static const OUString StrAllFiles = []()
+        {
+            const SolarMutexGuard guard;
+            std::locale loc = Translate::Create("fps");
+            return Translate::get(STR_FILTERNAME_ALL, loc);
+        }();
+
     // All files at top:
-    xFilePicker->appendFilter( StrAllFiles::get(), "*.*" );
+    xFilePicker->appendFilter( StrAllFiles, "*.*" );
     xFilePicker->appendFilter( DpResId(RID_STR_ALL_SUPPORTED), supportedFilters.makeStringAndClear() );
     // then supported ones:
     for (auto const& elem : title2filter)
diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx
index aafa45e239e0..d24811621d72 100644
--- a/desktop/source/deployment/misc/dp_misc.cxx
+++ b/desktop/source/deployment/misc/dp_misc.cxx
@@ -70,11 +70,7 @@ struct UnoRc : public rtl::StaticWithInit<
     }
 };
 
-struct OfficePipeId : public rtl::StaticWithInit<OUString, OfficePipeId> {
-    OUString operator () ();
-};
-
-OUString OfficePipeId::operator () ()
+OUString generateOfficePipeId()
 {
     OUString userPath;
     ::utl::Bootstrap::PathStatus aLocateResult =
@@ -113,7 +109,9 @@ OUString OfficePipeId::operator () ()
 
 bool existsOfficePipe()
 {
-    OUString const & pipeId = OfficePipeId::get();
+    static OUString OfficePipeId = generateOfficePipeId();
+
+    OUString const & pipeId = OfficePipeId;
     if (pipeId.isEmpty())
         return false;
     ::osl::Security sec;
diff --git a/i18nlangtag/source/languagetag/languagetag.cxx b/i18nlangtag/source/languagetag/languagetag.cxx
index 850e404e363c..a5a5dea7d0af 100644
--- a/i18nlangtag/source/languagetag/languagetag.cxx
+++ b/i18nlangtag/source/languagetag/languagetag.cxx
@@ -51,7 +51,6 @@ struct myLtError
 
 // "statics" to be returned as const reference to an empty locale and string.
 struct theEmptyLocale : public rtl::Static< lang::Locale, theEmptyLocale > {};
-struct theEmptyBcp47 : public rtl::Static< OUString, theEmptyBcp47 > {};
 }
 
 typedef std::unordered_set< OUString > KnownTagSet;
@@ -1561,8 +1560,10 @@ const OUString & LanguageTagImpl::getBcp47() const
 
 const OUString & LanguageTag::getBcp47( bool bResolveSystem ) const
 {
+    static const OUString theEmptyBcp47 = u"";
+
     if (!bResolveSystem && mbSystemLocale)
-        return theEmptyBcp47::get();
+        return theEmptyBcp47;
     if (!mbInitializedBcp47)
         syncVarsFromImpl();
     if (!mbInitializedBcp47)


More information about the Libreoffice-commits mailing list