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 <hjk@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Alessandro Portale
2024-03-06 15:09:30 +01:00
parent db5ac2dc15
commit 19feaad265

View File

@@ -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<AndroidDevice *>(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<AndroidDevice *>(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);
});
}
};