From 34a884a52a8e20ac7f8392494a843581d412bbaa Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Wed, 25 Aug 2021 16:23:21 +0200 Subject: [PATCH] Android: Clean up messed up kits that were created by Android plugin No idea how to reproduce, but it can happen [1] that stale Android kits appear in Qt Creator, which have broken combinations of Qt version and toolchains. The Android plugin updates the Android kits at startup, but only updates known "correct" kits, or creates new ones. Additionally remove any previously auto-created Android kits that were not recognized to be still usable. [1]: probably after switching between a working Android setup and a broken one, with broken toolchains/debuggers brought into the mix Change-Id: I709f52df62f8998647e4d68bdfe76015e8941ab8 Reviewed-by: Alessandro Portale --- src/plugins/android/androidconfigurations.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/plugins/android/androidconfigurations.cpp b/src/plugins/android/androidconfigurations.cpp index c93d5a78f2c..9d5f8713007 100644 --- a/src/plugins/android/androidconfigurations.cpp +++ b/src/plugins/android/androidconfigurations.cpp @@ -1290,10 +1290,7 @@ void AndroidConfigurations::updateAutomaticKitList() Utils::Id deviceTypeId = DeviceTypeKitAspect::deviceTypeId(k); if (k->isAutoDetected() && !k->isSdkProvided() && deviceTypeId == Utils::Id(Constants::ANDROID_DEVICE_TYPE)) { - if (!QtSupport::QtKitAspect::qtVersion(k)) - KitManager::deregisterKit(k); // Remove autoDetected kits without Qt. - else - return true; + return true; } return false; }); @@ -1327,6 +1324,7 @@ void AndroidConfigurations::updateAutomaticKitList() && tc->isValid() && tc->typeId() == Constants::ANDROID_TOOLCHAIN_TYPEID; }); + QList unhandledKits = existingKits; for (ToolChain *tc : toolchains) { if (tc->language() != Utils::Id(ProjectExplorer::Constants::CXX_LANGUAGE_ID)) continue; @@ -1381,12 +1379,18 @@ void AndroidConfigurations::updateAutomaticKitList() k->setValueSilently(Constants::ANDROID_KIT_SDK, currentConfig().sdkLocation().toString()); }; - if (existingKit) + if (existingKit) { initializeKit(existingKit); // Update the existing kit with new data. - else + unhandledKits.removeOne(existingKit); + } else { KitManager::registerKit(initializeKit); + } } } + // cleanup any mess that might have existed before, by removing all Android kits that + // existed before, but weren't re-used + for (Kit *k : unhandledKits) + KitManager::deregisterKit(k); } bool AndroidConfigurations::force32bitEmulator()