summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorAron Budea <aron.budea@collabora.com>2017-05-07 01:49:08 +0200
committerMichael Meeks <michael.meeks@collabora.com>2017-05-08 14:51:09 +0200
commitf9f511317fa5f1c655d189a8507f8a5492a3b08d (patch)
tree576aed837186a4ca0b039014050154a418751e30 /desktop
parent410d96db06cf13e8e081cef6fc3d9a9cd24ddbcd (diff)
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@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/app/app.cxx23
1 files changed, 14 insertions, 9 deletions
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 );