Android: Fix a possible crash after reloading packages

The AndroidSdkManager::packagesReloaded() signal emission will
trigger the connected slots in this order:
1. AndroidSettingsWidget::showEvent()'s lambda
2. AndroidSdkModel::refreshData()

However, the 1st slot may execute the nested event loop which
will cause the other GUI parts to be repainted. Since AndroidSdkModel
wasn't notified yet about the packagesReloaded(), it still holds the
data to the already deleted packages. The repaint will lead to
reading the data from already deleted objects.

The fix is to ensure the order of called slots is opposite,
by queueing a call to AndroidSettingsWidget::showEvent()'s lambda.

Change-Id: I090f0a44c3785a711a08f0eb985e2025cf3a923a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Jarek Kobus
2024-12-13 09:50:54 +01:00
parent 1fcfe14a9d
commit 55b75f7045

View File

@@ -520,7 +520,10 @@ void AndroidSettingsWidget::showEvent(QShowEvent *event)
m_androidSummary->setInProgressText("Packages reloaded"); m_androidSummary->setInProgressText("Packages reloaded");
m_sdkLocationPathChooser->triggerChanged(); m_sdkLocationPathChooser->triggerChanged();
validateSdk(); validateSdk();
}); }, Qt::QueuedConnection); // Hack: Let AndroidSdkModel::refreshData() be called first,
// otherwise the nested loop inside validateSdk() may trigger
// the repaint for the old data, containing pointers
// to the deleted packages. That's why we queue the signal.
}); });
validateOpenSsl(); validateOpenSsl();
m_isInitialReloadDone = true; m_isInitialReloadDone = true;