From 1ec9d9705f556c029a072fe8cf61c3073359a022 Mon Sep 17 00:00:00 2001 From: scorpio810 Date: Thu, 19 Dec 2013 16:11:52 +0000 Subject: [PATCH] Replacing getenv function in Windows, thanks Francisco git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2661 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/qetapp.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/sources/qetapp.cpp b/sources/qetapp.cpp index 4ba5eaf6b..d85c7a0da 100644 --- a/sources/qetapp.cpp +++ b/sources/qetapp.cpp @@ -35,6 +35,7 @@ #include #define QUOTE(x) STRINGIFY(x) #define STRINGIFY(x) #x +#include #ifdef QET_ALLOW_OVERRIDE_CED_OPTION QString QETApp::common_elements_dir = QString(); @@ -389,11 +390,15 @@ TitleBlockTemplatesCollection *QETApp::titleBlockTemplatesCollection(const QStri @return le nom de l'utilisateur courant */ QString QETApp::userName() { + QProcess * process = new QProcess(); #ifndef Q_OS_WIN32 - return(QString(getenv("USER"))); + // return(QString(getenv("USER"))); + return((process->processEnvironment()).value("USER", "UNKNOWN")); #else - return(QString(getenv("USERNAME"))); + // return(QString(getenv("USERNAME"))); + return((process->processEnvironment()).value("USERNAME", "UNKNOWN")); #endif + delete process; } /** @@ -473,9 +478,12 @@ QString QETApp::configDir() { #endif #ifdef Q_OS_WIN32 // recupere l'emplacement du dossier Application Data - char *app_data_env = getenv("APPDATA"); - QString app_data_str(app_data_env); - delete app_data_env; + // char *app_data_env = getenv("APPDATA"); + // QString app_data_str(app_data_env); + QProcess * process = new QProcess(); + QString app_data_str = (process->processEnvironment()).value("APPDATA"); + // delete app_data_env; + delete process; if (app_data_str.isEmpty()) { app_data_str = QDir::homePath() + "/Application Data"; }