From e5820febc7cbfd0d0c42b085da567d283a46c241 Mon Sep 17 00:00:00 2001 From: Sergei Tachenov Date: Thu, 15 Jan 2026 13:40:28 +0200 Subject: [PATCH] [UI, Wayland] IJPL-222880 Clean up ActionMenu UsabilityHelper GitOrigin-RevId: 20deef38812595711e9993cf0878db7714ff96ff --- .../openapi/actionSystem/impl/ActionMenu.kt | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenu.kt b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenu.kt index a8b253179187..5e99f90a5e8e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenu.kt +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenu.kt @@ -454,16 +454,20 @@ private class UsabilityHelper(component: Component) : IdeEventQueue.NonLockedEve */ private var window: Component? = ComponentUtil.getWindow(component) private var component: Component? = component - private var startMousePoint: Point? = null - private var xClosestToTargetSoFar = 0 - private var closestHorizontalDistanceSoFar = 0 - private var targetBounds: Rectangle? = null - private var upperTargetPoint: Point? = null - private var lowerTargetPoint: Point? = null private var eventToRedispatch: MouseEvent? = null private val pendingDispatchFlow = MutableStateFlow(false) private var done = false + // The stuff above needs to be cleaned up on dispose to avoid leaks. + // The stuff below only holds cached computations. + + private var startMousePoint: Point? = null + private var targetBounds: Rectangle? = null + private var upperTargetPoint: Point? = null + private var lowerTargetPoint: Point? = null + private var xClosestToTargetSoFar = 0 + private var closestHorizontalDistanceSoFar = 0 + init { component.launchOnShow("ActionMenu.UsabilityHelper") { pendingDispatchFlow.debounce(50.milliseconds).collect { dispatch -> @@ -567,9 +571,6 @@ private class UsabilityHelper(component: Component) : IdeEventQueue.NonLockedEve window = null component = null eventToRedispatch = null - lowerTargetPoint = null - upperTargetPoint = null - startMousePoint = null Toolkit.getDefaultToolkit().removeAWTEventListener(this) } }