mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[dynamic plugins] applicationShuttingDown is still required #IDEA-246104
GitOrigin-RevId: 65a917558d890bf358d0e0ba4715cdedd8fd6a63
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f6297836e4
commit
e7a9defa08
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.ide.plugins
|
||||
|
||||
import com.intellij.ide.AppLifecycleListener
|
||||
import com.intellij.openapi.application.ApplicationManager.getApplication
|
||||
import com.intellij.openapi.components.*
|
||||
import com.intellij.openapi.extensions.ExtensionNotApplicableException
|
||||
@@ -70,20 +71,33 @@ internal class ProjectPluginTracker(project: Project) : PersistentStateComponent
|
||||
}
|
||||
|
||||
private fun updatePluginEnabledState(project: Project, enable: Boolean) {
|
||||
getInstance(project).state
|
||||
.updatePluginEnabledState(project, enable)
|
||||
val pluginTracker = getInstance(project)
|
||||
if (pluginTracker.applicationShuttingDown) return
|
||||
|
||||
pluginTracker.state.updatePluginEnabledState(project, enable)
|
||||
}
|
||||
}
|
||||
|
||||
private var state = State()
|
||||
private var applicationShuttingDown = false
|
||||
|
||||
init {
|
||||
getApplication().messageBus.connect(project).subscribe(
|
||||
val connection = getApplication().messageBus.connect(project)
|
||||
connection.subscribe(
|
||||
ProjectManager.TOPIC,
|
||||
object : ProjectManagerListener {
|
||||
override fun projectClosing(project: Project) = updatePluginEnabledState(project, false)
|
||||
}
|
||||
)
|
||||
|
||||
connection.subscribe(
|
||||
AppLifecycleListener.TOPIC,
|
||||
object : AppLifecycleListener {
|
||||
override fun appWillBeClosed(isRestart: Boolean) {
|
||||
applicationShuttingDown = true
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
override fun getState(): State = state
|
||||
|
||||
Reference in New Issue
Block a user