From 06427a038b42023b44aa5690596636c11637c837 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Thu, 30 Mar 2023 18:31:09 +0200 Subject: [PATCH] Android: Force reset/update of pre-existing toolchains Toolchains are only (re-)created if the NDK changes. And till now, the environment for the toolchain was only set during its creation. However, if the user only changes the JDK location, we don't want to recreate the toolchain but to still update the JAVA_HOME variable for the environment. This change does so that resetToolChain() is called also for pre- existing toolchains (not just the newly created ones). That triggers a call of addToEnvironment(), which sets the potentially updated JAVA_HOME variable. Fixes: QTCREATORBUG-28827 Change-Id: Id55f59f3ef3c8bfbb2b811052e0f60f495843dc3 Reviewed-by: Assam Boudjelthia --- src/plugins/android/androidtoolchain.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/android/androidtoolchain.cpp b/src/plugins/android/androidtoolchain.cpp index 00335be2ef1..7af3bb417b6 100644 --- a/src/plugins/android/androidtoolchain.cpp +++ b/src/plugins/android/androidtoolchain.cpp @@ -230,9 +230,14 @@ ToolChainList AndroidToolChainFactory::autodetectToolChainsFromNdks( atc->setPlatformCodeGenFlags({"-target", target}); atc->setPlatformLinkerFlags({"-target", target}); atc->setDisplayName(displayName); - atc->resetToolChain(compilerCommand); tc = atc; } + + // Do not only reset newly created toolchains. This triggers call to + // addToEnvironment, so that e.g. JAVA_HOME gets updated. + if (auto gccTc = dynamic_cast(tc)) + gccTc->resetToolChain(compilerCommand); + tc->setDetection(ToolChain::AutoDetection); result << tc; ++targetItr;