check for project disposed in NewKotlinActivityAction (EA-82450 - assert: ComponentManagerImpl.getPicoContainer)
This commit is contained in:
+9
-2
@@ -183,14 +183,21 @@ class NewKotlinActivityAction: AnAction(KotlinIcons.ACTIVITY) {
|
|||||||
|
|
||||||
override fun update(e: AnActionEvent) {
|
override fun update(e: AnActionEvent) {
|
||||||
val view = LangDataKeys.IDE_VIEW.getData(e.dataContext)
|
val view = LangDataKeys.IDE_VIEW.getData(e.dataContext)
|
||||||
val module = LangDataKeys.MODULE.getData(e.dataContext)
|
val facet = getKotlinFacet(e)
|
||||||
val facet = if (module != null) AndroidFacet.getInstance(module) else null
|
|
||||||
val presentation = e.presentation
|
val presentation = e.presentation
|
||||||
val isProjectReady = facet != null && isProjectReady(facet)
|
val isProjectReady = facet != null && isProjectReady(facet)
|
||||||
presentation.text = "Kotlin Activity" + if (isProjectReady) "" else " (Project not ready)"
|
presentation.text = "Kotlin Activity" + if (isProjectReady) "" else " (Project not ready)"
|
||||||
presentation.isVisible = view != null && facet != null && isVisible(facet)
|
presentation.isVisible = view != null && facet != null && isVisible(facet)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getKotlinFacet(e: AnActionEvent): AndroidFacet? {
|
||||||
|
val project = e.project
|
||||||
|
if (project == null || project.isDisposed) return null
|
||||||
|
val module = LangDataKeys.MODULE.getData(e.dataContext)
|
||||||
|
val facet = if (module != null) AndroidFacet.getInstance(module) else null
|
||||||
|
return facet
|
||||||
|
}
|
||||||
|
|
||||||
private fun isVisible(facet: AndroidFacet): Boolean {
|
private fun isVisible(facet: AndroidFacet): Boolean {
|
||||||
try {
|
try {
|
||||||
val shouldSetVisible = AndroidFacet::class.memberFunctions.singleOrNull {
|
val shouldSetVisible = AndroidFacet::class.memberFunctions.singleOrNull {
|
||||||
|
|||||||
Reference in New Issue
Block a user