diff options
author | Aron Budea <aron.budea@collabora.com> | 2017-05-07 01:49:08 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-05-16 11:39:06 +0200 |
commit | aafb6a75c7461362aceddeadfbf0db0848af866c (patch) | |
tree | 0a724036980a21e5bb852c7879e31576b31c550c | |
parent | 45b2e11a6756ed322cda932142c31366fc2b6da6 (diff) |
tdf#104312, tdf#105428: use static vars in ReplaceStringHookProc
And use call_once to initialize them once.
Reviewed-on: https://gerrit.libreoffice.org/37318
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
(cherry picked from commit f9f511317fa5f1c655d189a8507f8a5492a3b08d)
Change-Id: Ic2f97a51ccc6ee400eb1af56da2c8fd88e226a9d
Reviewed-on: https://gerrit.libreoffice.org/37410
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | desktop/source/app/app.cxx | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 879369714580..1f9307d0c26f 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -23,6 +23,7 @@ #include <sal/config.h> #include <iostream> +#include <mutex> #if defined UNX #include <signal.h> #endif @@ -473,16 +474,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() ) { @@ -490,12 +492,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 ); |