diff options
author | Noel Grandin <noel@peralex.com> | 2015-11-06 09:23:33 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2015-11-09 08:34:40 +0000 |
commit | 6c80a8fe89fadf9a2c7260a09c037a09462f53d1 (patch) | |
tree | d36da9ee2a5fdc579d2a57ff6ba02deaddfa785a /vcl/unx | |
parent | e1fc599eb764186e5d511ace9785463eebbc7028 (diff) |
new loplugin: oncevar
Change-Id: If57390510dde4d166be3141b9f658a7453755d3f
Reviewed-on: https://gerrit.libreoffice.org/19815
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'vcl/unx')
-rw-r--r-- | vcl/unx/generic/desktopdetect/desktopdetector.cxx | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/vcl/unx/generic/desktopdetect/desktopdetector.cxx b/vcl/unx/generic/desktopdetect/desktopdetector.cxx index 2f8ee6629842..f769bf075438 100644 --- a/vcl/unx/generic/desktopdetect/desktopdetector.cxx +++ b/vcl/unx/generic/desktopdetect/desktopdetector.cxx @@ -231,18 +231,18 @@ static bool is_tde_desktop( Display* pDisplay ) return false; } -static bool is_kde_desktop( Display* pDisplay ) +static bool is_kde3_desktop( Display* pDisplay ) { - if ( NULL != getenv( "KDE_FULL_SESSION" ) ) + static const char * pFullVersion = getenv( "KDE_FULL_SESSION" ); + static const char * pSessionVersion = getenv( "KDE_SESSION_VERSION" ); + if ( pFullVersion ) { - const char *pVer = getenv( "KDE_SESSION_VERSION" ); - if ( !pVer || pVer[0] == '0' ) + if ( !pSessionVersion || pSessionVersion[0] == '0' ) { return true; // does not exist => KDE3 } - OUString aVer( "3" ); - if ( aVer.equalsIgnoreAsciiCaseAscii( pVer ) ) + if ( strcmp(pSessionVersion, "3" ) == 0 ) { return true; } @@ -256,14 +256,10 @@ static bool is_kde_desktop( Display* pDisplay ) static bool is_kde4_desktop( Display* pDisplay ) { - if ( NULL != getenv( "KDE_FULL_SESSION" ) ) - { - OUString aVer( "4" ); - - const char *pVer = getenv( "KDE_SESSION_VERSION" ); - if ( pVer && aVer.equalsIgnoreAsciiCaseAscii( pVer ) ) - return true; - } + static const char * pFullVersion = getenv( "KDE_FULL_SESSION" ); + static const char * pSessionVersion = getenv( "KDE_SESSION_VERSION" ); + if ( pFullVersion && pSessionVersion && strcmp(pSessionVersion, "4") == 0 ) + return true; if ( KDEVersion( pDisplay ) == 4 ) return true; @@ -273,14 +269,10 @@ static bool is_kde4_desktop( Display* pDisplay ) static bool is_kde5_desktop( Display* pDisplay ) { - if ( NULL != getenv( "KDE_FULL_SESSION" ) ) - { - OUString aVer( "5" ); - - const char *pVer = getenv( "KDE_SESSION_VERSION" ); - if ( pVer && aVer.equalsIgnoreAsciiCaseAscii( pVer ) ) - return true; - } + static const char * pFullVersion = getenv( "KDE_FULL_SESSION" ); + static const char * pSessionVersion = getenv( "KDE_SESSION_VERSION" ); + if ( pFullVersion && pSessionVersion && strcmp(pSessionVersion, "5") ) + return true; if ( KDEVersion( pDisplay ) == 5 ) return true; @@ -400,7 +392,7 @@ DESKTOP_DETECTOR_PUBLIC DesktopType get_desktop_environment() ret = DESKTOP_KDE4; else if ( is_gnome_desktop( pDisplay ) ) ret = DESKTOP_GNOME; - else if ( is_kde_desktop( pDisplay ) ) + else if ( is_kde3_desktop( pDisplay ) ) ret = DESKTOP_KDE3; else if ( is_tde_desktop( pDisplay ) ) ret = DESKTOP_TDE; |