From 19feaad265f40df546917f7cbe00e2a19c7cec08 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 6 Mar 2024 15:09:30 +0100 Subject: [PATCH] Android: Register AndroidDevice creator regardless of SDK state The AndroidDeviceFactory only registered the AndroidDevice creator function if the Android SDK was correctly set up. That check occurred only once during the Qt Creator start up sequence. As a consequence, Qt Creator had to be restarted after an initial set up of the Android SDK. Users are not notified of such requirement, and we actually don't want to enforce a restart. With this change, the AndroidDevice creator function is always registered, and the "Add Android Device" wizard always selectable. Users who try to add an Android device without having set up Android before get to see an info message box. Change-Id: I0600e36575c2dd075af9398597c3c8dab3bb243d Reviewed-by: hjk Reviewed-by: Christian Kandeler --- src/plugins/android/androiddevice.cpp | 35 +++++++++++++++------------ 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/plugins/android/androiddevice.cpp b/src/plugins/android/androiddevice.cpp index 1d87fa1ddd0..56ffbf45b9f 100644 --- a/src/plugins/android/androiddevice.cpp +++ b/src/plugins/android/androiddevice.cpp @@ -836,24 +836,27 @@ public: setCombinedIcon(":/android/images/androiddevicesmall.png", ":/android/images/androiddevice.png"); setConstructionFunction(&AndroidDevice::create); - if (androidConfig().sdkToolsOk()) { - setCreator([] { - AvdDialog dialog = AvdDialog(Core::ICore::dialogParent()); - if (dialog.exec() != QDialog::Accepted) - return IDevice::Ptr(); + setCreator([] { + if (!androidConfig().sdkToolsOk()) { + AndroidDeviceWidget::infoDialog(Tr::tr("Android support is not yet configured.")); + return IDevice::Ptr(); + } - const IDevice::Ptr dev = dialog.device(); - if (const auto androidDev = static_cast(dev.get())) { - qCDebug(androidDeviceLog, "Created new Android AVD id \"%s\".", - qPrintable(androidDev->avdName())); - } else { - AndroidDeviceWidget::criticalDialog( - Tr::tr("The device info returned from AvdDialog is invalid.")); - } + AvdDialog dialog = AvdDialog(Core::ICore::dialogParent()); + if (dialog.exec() != QDialog::Accepted) + return IDevice::Ptr(); - return IDevice::Ptr(dev); - }); - } + const IDevice::Ptr dev = dialog.device(); + if (const auto androidDev = static_cast(dev.get())) { + qCDebug(androidDeviceLog, "Created new Android AVD id \"%s\".", + qPrintable(androidDev->avdName())); + } else { + AndroidDeviceWidget::criticalDialog( + Tr::tr("The device info returned from AvdDialog is invalid.")); + } + + return IDevice::Ptr(dev); + }); } };