[qet] [2661] Replacing getenv function in Windows, thanks Francisco

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 2661
Author:   scorpio810
Date:     2013-12-19 17:11:52 +0100 (Thu, 19 Dec 2013)
Log Message:
-----------
Replacing getenv function in Windows, thanks Francisco

Modified Paths:
--------------
    trunk/sources/qetapp.cpp

Modified: trunk/sources/qetapp.cpp
===================================================================
--- trunk/sources/qetapp.cpp	2013-12-19 15:22:12 UTC (rev 2660)
+++ trunk/sources/qetapp.cpp	2013-12-19 16:11:52 UTC (rev 2661)
@@ -35,6 +35,7 @@
 #include <iostream>
 #define QUOTE(x) STRINGIFY(x)
 #define STRINGIFY(x) #x
+#include <QProcessEnvironment>
 
 #ifdef QET_ALLOW_OVERRIDE_CED_OPTION
 QString QETApp::common_elements_dir = QString();
@@ -389,11 +390,15 @@
 	@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 @@
 #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";
 	}


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/