From 7edd08ff12d4945527b4d3e11af7f58ab77a47c9 Mon Sep 17 00:00:00 2001 From: Patrick Ziegler Date: Sun, 28 Jul 2024 17:45:55 +0200 Subject: [PATCH] Avoid asynchronous task when calculating relative locations The getRelativeLocation() asynchronously calculates the screen location of the parent and child component. To calls should instead be done synchronously, to avoid any race conditions caused by window changes between those calls. Amends bee6c0d65382e283c3e337f6f373a715fa6c0914 --- .../src/org/eclipse/wb/internal/swing/utils/SwingUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.eclipse.wb.swing/src/org/eclipse/wb/internal/swing/utils/SwingUtils.java b/org.eclipse.wb.swing/src/org/eclipse/wb/internal/swing/utils/SwingUtils.java index 3d39af8e3..f4707fd3e 100644 --- a/org.eclipse.wb.swing/src/org/eclipse/wb/internal/swing/utils/SwingUtils.java +++ b/org.eclipse.wb.swing/src/org/eclipse/wb/internal/swing/utils/SwingUtils.java @@ -314,8 +314,8 @@ public static Point getRelativeLocation(final Component parentComponent, final C throws Exception { try { return runObjectLaterAndWait(() -> { - Point parentLocation = getScreenLocation(parentComponent); - Point childLocation = getScreenLocation(childComponent); + Point parentLocation = parentComponent.getLocationOnScreen(); + Point childLocation = childComponent.getLocationOnScreen(); int relX = childLocation.x - parentLocation.x; int relY = childLocation.y - parentLocation.y; return new Point(relX, relY);