summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorAron Budea <aron.budea@collabora.com>2017-05-07 01:49:08 +0200
committerJan Holesovsky <kendy@collabora.com>2017-05-16 11:32:51 +0200
commitd2f69fc9011c0f4360710629783e800b60cedd65 (patch)
tree0a1dd5adf091c0eab5959b0ee93132539f85e635 /desktop
parent708600e84cb3b20cbbc1f6eea5f7f039cba034a1 (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/37528 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/app/app.cxx24
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 );