• R/O
  • HTTP
  • SSH
  • HTTPS

MUtilities: Commit

MUtilities development repository


Commit MetaInfo

Revision89b73b90c9f13613554c193051c5e694b2c08aa9 (tree)
Time2018-10-23 06:09:52
AuthorLoRd_MuldeR <mulder2@gmx....>
CommiterLoRd_MuldeR

Log Message

Small improvement to init_process() function.

Change Summary

Incremental Difference

--- a/src/Global.cpp
+++ b/src/Global.cpp
@@ -540,34 +540,50 @@ static void prependToPath(QProcessEnvironment &env, const QString &value)
540540 void MUtils::init_process(QProcess &process, const QString &wokringDir, const bool bReplaceTempDir, const QStringList *const extraPaths, const QHash<QString, QString> *const extraEnv)
541541 {
542542 //Environment variable names
543- static const char *const s_envvar_names_temp[] =
543+ static const char *const ENVVAR_NAMES_TMP[] =
544544 {
545545 "TEMP", "TMP", "TMPDIR", "HOME", "USERPROFILE", "HOMEPATH", NULL
546546 };
547- static const char *const s_envvar_names_remove[] =
547+ static const char *const ENVVAR_NAMES_SYS[] =
548548 {
549- "WGETRC", "SYSTEM_WGETRC", "HTTP_PROXY", "FTP_PROXY", "NO_PROXY", "GNUPGHOME", "LC_ALL", "LC_COLLATE", "LC_CTYPE", "LC_MESSAGES", "LC_MONETARY", "LC_NUMERIC", "LC_TIME", "LANG", NULL
549+ "WINDIR", "SYSTEMROOT", NULL
550+ };
551+ static const char *const ENVVAR_NAMES_DEL[] =
552+ {
553+ "HTTP_PROXY", "FTP_PROXY", "NO_PROXY", "HOME", "LC_ALL", "LC_COLLATE", "LC_CTYPE",
554+ "LC_MESSAGES", "LC_MONETARY", "LC_NUMERIC", "LC_TIME", "LANG", NULL
550555 };
551556
552557 //Initialize environment
553558 QProcessEnvironment env = process.processEnvironment();
554- if(env.isEmpty()) env = QProcessEnvironment::systemEnvironment();
559+ if (env.isEmpty())
560+ {
561+ env = QProcessEnvironment::systemEnvironment();
562+ }
555563
556- //Clean a number of enviroment variables that might affect our tools
557- for(size_t i = 0; s_envvar_names_remove[i]; i++)
564+ //Clean enviroment variables that might affect our tools
565+ for(const char *const *ptr = ENVVAR_NAMES_DEL; *ptr; ++ptr)
558566 {
559- env.remove(QString::fromLatin1(s_envvar_names_remove[i]));
560- env.remove(QString::fromLatin1(s_envvar_names_remove[i]).toLower());
567+ env.remove(QString::fromLatin1(*ptr));
561568 }
562569
563- const QString tempDir = QDir::toNativeSeparators(temp_folder());
570+ //Set up system root directory
571+ const QString sysRoot = QDir::toNativeSeparators(OS::known_folder(OS::FOLDER_SYSTROOT_DIR));
572+ if (!sysRoot.isEmpty())
573+ {
574+ for (const char *const *ptr = ENVVAR_NAMES_SYS; *ptr; ++ptr)
575+ {
576+ env.insert(QString::fromLatin1(*ptr), sysRoot);
577+ }
578+ }
564579
565580 //Replace TEMP directory in environment
581+ const QString tempDir = QDir::toNativeSeparators(temp_folder());
566582 if(bReplaceTempDir)
567583 {
568- for(size_t i = 0; s_envvar_names_temp[i]; i++)
584+ for (const char *const *ptr = ENVVAR_NAMES_TMP; *ptr; ++ptr)
569585 {
570- env.insert(s_envvar_names_temp[i], tempDir);
586+ env.insert(QString::fromLatin1(*ptr), tempDir);
571587 }
572588 }
573589
--- a/src/UpdateChecker.cpp
+++ b/src/UpdateChecker.cpp
@@ -104,8 +104,10 @@ static QQueue<QString> buildRandomList(const char *const *values)
104104
105105 static const QHash<QString, QString> *initEnvVars(void)
106106 {
107+ const QString tempfolder = QDir::toNativeSeparators(MUtils::temp_folder());
107108 QHash<QString, QString> *const environment = new QHash<QString, QString>();
108- environment->insert(QLatin1String("CURL_HOME"), QDir::toNativeSeparators(MUtils::temp_folder()));
109+ environment->insert(QLatin1String("CURL_HOME"), tempfolder);
110+ environment->insert(QLatin1String("GNUPGHOME"), tempfolder);
109111 return environment;
110112 }
111113
Show on old repository browser