From 30bca7a119c41d3f863c682a2431440d628d21db Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 22 Dec 2020 16:22:45 +0100 Subject: [PATCH] dtoolutil: fix ExecutionEnvironment::has_environment_variable() for shadowed var Fixes MAIN_DIR being set more than once (which seems to avoid a compiler bug in an opt4 build). --- dtool/src/dtoolutil/executionEnvironment.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dtool/src/dtoolutil/executionEnvironment.cxx b/dtool/src/dtoolutil/executionEnvironment.cxx index ca8f45d876..96ae7fd147 100644 --- a/dtool/src/dtoolutil/executionEnvironment.cxx +++ b/dtool/src/dtoolutil/executionEnvironment.cxx @@ -217,9 +217,11 @@ get_cwd() { */ bool ExecutionEnvironment:: ns_has_environment_variable(const string &var) const { -#ifdef PREREAD_ENVIRONMENT - return _variables.count(var) != 0; -#else + if (_variables.count(var) != 0) { + return true; + } + +#ifndef PREREAD_ENVIRONMENT return getenv(var.c_str()) != nullptr; #endif }