|
13 | 13 | #include <qtypes.h> |
14 | 14 | #include <qvariant.h> |
15 | 15 |
|
| 16 | +#include "../core/common.hpp" |
16 | 17 | #include "../core/generation.hpp" |
17 | 18 | #include "../core/qmlglobal.hpp" |
18 | 19 | #include "datastream.hpp" |
@@ -223,26 +224,24 @@ void Process::setupEnvironment(QProcess* process) { |
223 | 224 | process->setWorkingDirectory(this->mWorkingDirectory); |
224 | 225 | } |
225 | 226 |
|
226 | | - if (!this->mEnvironment.isEmpty() || this->mClearEnvironment) { |
227 | | - auto sysenv = QProcessEnvironment::systemEnvironment(); |
228 | | - auto env = this->mClearEnvironment ? QProcessEnvironment() : sysenv; |
229 | | - |
230 | | - for (auto& name: this->mEnvironment.keys()) { |
231 | | - auto value = this->mEnvironment.value(name); |
232 | | - if (!value.isValid()) continue; |
233 | | - |
234 | | - if (this->mClearEnvironment) { |
235 | | - if (value.isNull()) { |
236 | | - if (sysenv.contains(name)) env.insert(name, sysenv.value(name)); |
237 | | - } else env.insert(name, value.toString()); |
238 | | - } else { |
239 | | - if (value.isNull()) env.remove(name); |
240 | | - else env.insert(name, value.toString()); |
241 | | - } |
242 | | - } |
| 227 | + const auto& sysenv = qs::Common::INITIAL_ENVIRONMENT; |
| 228 | + auto env = this->mClearEnvironment ? QProcessEnvironment() : sysenv; |
| 229 | + |
| 230 | + for (auto& name: this->mEnvironment.keys()) { |
| 231 | + auto value = this->mEnvironment.value(name); |
| 232 | + if (!value.isValid()) continue; |
243 | 233 |
|
244 | | - process->setProcessEnvironment(env); |
| 234 | + if (this->mClearEnvironment) { |
| 235 | + if (value.isNull()) { |
| 236 | + if (sysenv.contains(name)) env.insert(name, sysenv.value(name)); |
| 237 | + } else env.insert(name, value.toString()); |
| 238 | + } else { |
| 239 | + if (value.isNull()) env.remove(name); |
| 240 | + else env.insert(name, value.toString()); |
| 241 | + } |
245 | 242 | } |
| 243 | + |
| 244 | + process->setProcessEnvironment(env); |
246 | 245 | } |
247 | 246 |
|
248 | 247 | void Process::onStarted() { |
|
0 commit comments