From 5bfc566e1c74bd17e4008c6ffcb48317163bde1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomek=20jean=20Ma=C5=84ko?= Date: Thu, 27 Jun 2024 08:05:09 +0200 Subject: [PATCH] IJPL-13205 Fix setting status label update when deleting remote data Since the even handler runs in a different thread from the progress modal, `ModalityKt.defaultModalityImpl()` won't be able to get it from `ProgressManager.getInstanceOrNull()?.currentProgressModality`, causing the modality state to fall back to non-modal, delaying the label update until after the settings dialog is closed. It's fixed by just storing the settings dialog modality state before showing the progress modal and passing it to `runInEdt` explicitly. Signed-off-by: Sergey Pak GitOrigin-RevId: ae45788cc3f16bb92e2bad666ba16b733762a216 --- .../settingsSync/config/SettingsSyncConfigurable.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/settings-sync/src/com/intellij/settingsSync/config/SettingsSyncConfigurable.kt b/plugins/settings-sync/src/com/intellij/settingsSync/config/SettingsSyncConfigurable.kt index f39455692d61..7c09bf5bc00b 100644 --- a/plugins/settings-sync/src/com/intellij/settingsSync/config/SettingsSyncConfigurable.kt +++ b/plugins/settings-sync/src/com/intellij/settingsSync/config/SettingsSyncConfigurable.kt @@ -7,6 +7,7 @@ import com.intellij.ide.plugins.PluginManagerConfigurable import com.intellij.ide.plugins.PluginStateManager import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.ApplicationNamesInfo +import com.intellij.openapi.application.ModalityState import com.intellij.openapi.application.ex.ApplicationEx import com.intellij.openapi.application.runInEdt import com.intellij.openapi.components.impl.stores.stateStore @@ -359,11 +360,14 @@ internal class SettingsSyncConfigurable : BoundConfigurable(message("title.setti } private fun disableAndRemoveData() { + val modality = ModalityState.current(); + object : Task.Modal(null, message("disable.remove.data.title"), false) { override fun run(indicator: ProgressIndicator) { val cdl = CountDownLatch(1) SettingsSyncEvents.getInstance().fireSettingsChanged(SyncSettingsEvent.DeleteServerData { result -> cdl.countDown() + when (result) { is DeleteServerDataResult.Error -> { runInEdt { @@ -371,12 +375,13 @@ internal class SettingsSyncConfigurable : BoundConfigurable(message("title.setti } } DeleteServerDataResult.Success -> { - runInEdt { + runInEdt(modality) { updateStatusInfo() } } } }) + cdl.await(1, TimeUnit.MINUTES) } }.queue()