IJPL-172029: vcs marker: Fix disposing

(cherry picked from commit 06626edc93dcb233ed21e546ba16cd266462caaa)

IJ-CR-149651

GitOrigin-RevId: c0e59976528fb09fc3379a5da9c01d7b8cc84113
This commit is contained in:
Aleksandr Krasilnikov
2024-11-20 15:42:22 +01:00
committed by intellij-monorepo-bot
parent 1d0ecfe682
commit 96e9c11cb6

View File

@@ -18,6 +18,7 @@ import com.intellij.openapi.editor.actionSystem.EditorActionHandler
import com.intellij.openapi.editor.event.* import com.intellij.openapi.editor.event.*
import com.intellij.openapi.fileEditor.FileEditorManagerEvent import com.intellij.openapi.fileEditor.FileEditorManagerEvent
import com.intellij.openapi.fileEditor.FileEditorManagerListener import com.intellij.openapi.fileEditor.FileEditorManagerListener
import com.intellij.openapi.util.CheckedDisposable
import com.intellij.openapi.util.Disposer import com.intellij.openapi.util.Disposer
import com.intellij.ui.EditorTextComponent import com.intellij.ui.EditorTextComponent
import com.intellij.ui.HintHint import com.intellij.ui.HintHint
@@ -32,7 +33,7 @@ import java.awt.event.MouseAdapter
@Service(Service.Level.APP) @Service(Service.Level.APP)
class LineStatusMarkerPopupService { class LineStatusMarkerPopupService {
private var activePopupDisposable: Disposable? = null private var activePopupDisposable: CheckedDisposable? = null
@RequiresEdt @RequiresEdt
fun buildAndShowPopup(parentDisposable: Disposable, editor: Editor, mousePosition: Point?, builder: (popupDisposable: Disposable) -> LineStatusMarkerPopupPanel) { fun buildAndShowPopup(parentDisposable: Disposable, editor: Editor, mousePosition: Point?, builder: (popupDisposable: Disposable) -> LineStatusMarkerPopupPanel) {
@@ -41,9 +42,9 @@ class LineStatusMarkerPopupService {
showPopupAt(editor, markerPopupPanel, mousePosition, popupDisposable) showPopupAt(editor, markerPopupPanel, mousePosition, popupDisposable)
} }
private fun getNextPopupDisposable(parentDisposable: Disposable): Disposable { private fun getNextPopupDisposable(parentDisposable: Disposable): CheckedDisposable {
closeActivePopup() closeActivePopup()
activePopupDisposable = Disposer.newDisposable(parentDisposable, "LineStatusMarkerPopup") activePopupDisposable = Disposer.newCheckedDisposable(parentDisposable, "LineStatusMarkerPopup")
return activePopupDisposable!! return activePopupDisposable!!
} }
@@ -57,8 +58,10 @@ class LineStatusMarkerPopupService {
editor: Editor, editor: Editor,
panel: LineStatusMarkerPopupPanel, panel: LineStatusMarkerPopupPanel,
mousePosition: Point?, mousePosition: Point?,
popupDisposable: Disposable, popupDisposable: CheckedDisposable,
) { ) {
if (popupDisposable.isDisposed) return
val hint = LightweightHint(panel) val hint = LightweightHint(panel)
Disposer.register(popupDisposable, Disposable { Disposer.register(popupDisposable, Disposable {
UIUtil.invokeLaterIfNeeded { UIUtil.invokeLaterIfNeeded {