IJPL-172200 IJPL-176167 prevent 'LaterInvocator.forceLeaveAllModals'-induced errors from cancelling IDE exit

(cherry picked from commit ee9547bb2963ffcdc7ebb832a7f28621cdcfe82f)
IJ-CR-156309

GitOrigin-RevId: 633c237c621400b1a9d48482f859b2931aee38b5
This commit is contained in:
Aleksey Pivovarov
2025-02-25 12:33:30 +01:00
committed by intellij-monorepo-bot
parent 368142924f
commit 37152190a5
3 changed files with 19 additions and 10 deletions

View File

@@ -285,6 +285,7 @@ private class SaveAndSyncHandlerImpl(private val coroutineScope: CoroutineScope)
title = getProgressTitle(componentManager),
cancellation = TaskCancellation.nonCancellable(),
) {
withContext(NonCancellable) {
// ensure that is fully canceled
currentJob?.join()
@@ -298,6 +299,7 @@ private class SaveAndSyncHandlerImpl(private val coroutineScope: CoroutineScope)
}
}
}
}
if (isAutoSaveCancelled) {
requestSave()

View File

@@ -674,9 +674,14 @@ public final class ApplicationImpl extends ClientAwareComponentManager implement
stopServicePreloading();
if (BitUtil.isSet(flags, SAVE)) {
try {
TraceKt.use(tracer.spanBuilder("saveSettingsOnExit"),
__ -> SaveAndSyncHandler.getInstance().saveSettingsUnderModalProgress(this));
}
catch (Throwable e) {
logErrorDuringExit("Failed to save settings", e);
}
}
if (isInstantShutdownPossible()) {
for (Frame frame : Frame.getFrames()) {

View File

@@ -23,6 +23,8 @@ sealed interface TaskCancellation {
companion object {
/**
* @return a cancellation instance, which means that the cancel button should not be displayed in the UI
*
* It does not indicate that the task is inside [kotlinx.coroutines.NonCancellable] section.
*/
@Contract(pure = true)
@JvmStatic