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

Aron Budea aron.budea at collabora.com
Mon May 8 12:51:45 UTC 2017


 desktop/source/app/app.cxx |   23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

New commits:
commit f9f511317fa5f1c655d189a8507f8a5492a3b08d
Author: Aron Budea <aron.budea at collabora.com>
Date:   Sun May 7 01:49:08 2017 +0200

    tdf#104312, tdf#105428: use static vars in ReplaceStringHookProc
    
    And use call_once to initialize them once.
    
    Change-Id: Ic2f97a51ccc6ee400eb1af56da2c8fd88e226a9d
    Reviewed-on: https://gerrit.libreoffice.org/37318
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index e3eabd7a2d68..45d9830ac25f 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -471,16 +471,17 @@ namespace
 
 OUString ReplaceStringHookProc( const OUString& rStr )
 {
-    OUString sRet(rStr);
+    const static OUString sBuildId(utl::Bootstrap::getBuildIdData("development"));
+    static OUString sBrandName, sVersion, sAboutBoxVersion, sAboutBoxVersionSuffix, sExtension;
 
-    if (sRet.indexOf("%PRODUCT") != -1 || sRet.indexOf("%ABOUTBOX") != -1)
+    static std::once_flag aInitOnce;
+    std::call_once(aInitOnce, []
     {
-        OUString sBrandName = BrandName::get();
-        OUString sVersion = Version::get();
-        OUString sBuildId = utl::Bootstrap::getBuildIdData("development");
-        OUString sAboutBoxVersion = AboutBoxVersion::get();
-        OUString sAboutBoxVersionSuffix = AboutBoxVersionSuffix::get();
-        OUString sExtension = Extension::get();
+        sBrandName = BrandName::get();
+        sVersion = Version::get();
+        sAboutBoxVersion = AboutBoxVersion::get();
+        sAboutBoxVersionSuffix =AboutBoxVersionSuffix::get();
+        sExtension = Extension::get();
 
         if ( sBrandName.isEmpty() )
         {
@@ -488,12 +489,16 @@ OUString ReplaceStringHookProc( const OUString& rStr )
             sVersion = utl::ConfigManager::getProductVersion();
             sAboutBoxVersion = utl::ConfigManager::getAboutBoxProductVersion();
             sAboutBoxVersionSuffix = utl::ConfigManager::getAboutBoxProductVersionSuffix();
-            if ( sExtension.isEmpty() )
+            if (sExtension.isEmpty())
             {
                 sExtension = utl::ConfigManager::getProductExtension();
             }
         }
+    } );
 
+    OUString sRet(rStr);
+    if (sRet.indexOf("%PRODUCT") != -1 || sRet.indexOf("%ABOUTBOX") != -1)
+    {
         sRet = sRet.replaceAll( "%PRODUCTNAME", sBrandName );
         sRet = sRet.replaceAll( "%PRODUCTVERSION", sVersion );
         sRet = sRet.replaceAll( "%BUILDID", sBuildId );


More information about the Libreoffice-commits mailing list