From 679a51d12b657fdda0f27af905ace5f3718de5cb Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 3 May 2024 16:57:24 +0200 Subject: Android: Create and execute AndroidSdkManagerWidget on demand There is no need to always instantiate it inside AndroidSettingsWidget. Force data refresh on model construction. Change-Id: I1adcd933e8684df9819d3dbd9cef2d615cff84a8 Reviewed-by: Reviewed-by: Alessandro Portale --- src/plugins/android/androidsdkmodel.cpp | 3 +++ src/plugins/android/androidsettingswidget.cpp | 18 ++++-------------- 2 files changed, 7 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/plugins/android/androidsdkmodel.cpp b/src/plugins/android/androidsdkmodel.cpp index 985e4a649a..c2b3ffdba3 100644 --- a/src/plugins/android/androidsdkmodel.cpp +++ b/src/plugins/android/androidsdkmodel.cpp @@ -30,6 +30,9 @@ AndroidSdkModel::AndroidSdkModel(AndroidSdkManager *sdkManager, QObject *parent) refreshData(); endResetModel(); }); + beginResetModel(); + refreshData(); + endResetModel(); } QVariant AndroidSdkModel::headerData(int section, Qt::Orientation orientation, int role) const diff --git a/src/plugins/android/androidsettingswidget.cpp b/src/plugins/android/androidsettingswidget.cpp index b6a1df3a60..f9d382ba5e 100644 --- a/src/plugins/android/androidsettingswidget.cpp +++ b/src/plugins/android/androidsettingswidget.cpp @@ -162,7 +162,6 @@ class AndroidSettingsWidget final : public Core::IOptionsPageWidget public: // Todo: This would be so much simpler if it just used Utils::PathChooser!!! AndroidSettingsWidget(); - ~AndroidSettingsWidget() final; private: void showEvent(QShowEvent *event) override; @@ -184,8 +183,6 @@ private: bool isDefaultNdkSelected() const; void validateOpenSsl(); - AndroidSdkManagerWidget *m_sdkManagerWidget = nullptr; - AndroidSdkManager m_sdkManager; Tasking::TaskTreeRunner m_sdkDownloader; bool m_isInitialReloadDone = false; @@ -341,9 +338,6 @@ AndroidSettingsWidget::AndroidSettingsWidget() "If the automatic download fails, Qt Creator proposes to open the download URL\n" "in the system's browser for manual download.")); - - m_sdkManagerWidget = new AndroidSdkManagerWidget(&m_sdkManager, this); - const QMap androidValidationPoints = { { JavaPathExistsAndWritableRow, Tr::tr("JDK path exists and is writable.") }, { SdkPathExistsAndWritableRow, Tr::tr("Android SDK path exists and is writable.") }, @@ -500,8 +494,10 @@ AndroidSettingsWidget::AndroidSettingsWidget() m_androidSummary->setInProgressText("Retrieving packages information"); m_androidProgress->show(); }); - connect(sdkManagerToolButton, &QAbstractButton::clicked, - this, [this] { m_sdkManagerWidget->exec(); }); + connect(sdkManagerToolButton, &QAbstractButton::clicked, this, [this] { + AndroidSdkManagerWidget dialog(&m_sdkManager, this); + dialog.exec(); + }); connect(sdkToolsAutoDownloadButton, &QAbstractButton::clicked, this, &AndroidSettingsWidget::downloadSdk); connect(&m_sdkDownloader, &Tasking::TaskTreeRunner::done, this, [this](Tasking::DoneWith result) { @@ -526,12 +522,6 @@ AndroidSettingsWidget::AndroidSettingsWidget() setOnApply([] { AndroidConfigurations::setConfig(androidConfig()); }); } -AndroidSettingsWidget::~AndroidSettingsWidget() -{ - // Deleting m_sdkManagerWidget will cancel all ongoing and pending sdkmanager operations. - delete m_sdkManagerWidget; -} - void AndroidSettingsWidget::showEvent(QShowEvent *event) { Q_UNUSED(event) -- cgit v1.2.3