File orca-large-set-oom.patch of Package orca
From f9784efaea501de126044f32f69331c4f7d8ebca Mon Sep 17 00:00:00 2001
From: Mike Gorse <mgorse@suse.com>
Date: Mon, 14 Jul 2025 09:27:24 -0500
Subject: [PATCH] AXComponent: Rewrite get_rect_intersection
This is likely more performant and avoids creating large sets that exhaust
the system's memory if we are passed a bad value.
Closes #560
---
src/orca/ax_component.py | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/src/orca/ax_component.py b/src/orca/ax_component.py
index e26135ca8..e632f9bef 100644
--- a/src/orca/ax_component.py
+++ b/src/orca/ax_component.py
@@ -92,19 +92,16 @@ class AXComponent:
result = Atspi.Rect()
- x_points1 = range(rect1.x, rect1.x + rect1.width + 1)
- x_points2 = range(rect2.x, rect2.x + rect2.width + 1)
- x_intersection = sorted(set(x_points1).intersection(set(x_points2)))
-
- y_points1 = range(rect1.y, rect1.y + rect1.height + 1)
- y_points2 = range(rect2.y, rect2.y + rect2.height + 1)
- y_intersection = sorted(set(y_points1).intersection(set(y_points2)))
-
- if x_intersection and y_intersection:
- result.x = x_intersection[0]
- result.y = y_intersection[0]
- result.width = x_intersection[-1] - result.x
- result.height = y_intersection[-1] - result.y
+ dest_x = max(rect1.x, rect2.x)
+ dest_y = max(rect1.y, rect2.y)
+ dest_x2 = min(rect1.x + rect1.width, rect2.x + rect2.width)
+ dest_y2 = min(rect1.y + rect1.height, rect2.y + rect2.height)
+
+ if dest_x2 > dest_x and dest_y2 > dest_y:
+ result.x = dest_x
+ result.y = dest_y
+ result.width = dest_x2 - dest_x
+ result.height = dest_y2 - dest_y
tokens = ["AXComponent: The intersection of", rect1, "and", rect2, "is:", result]
debug.print_tokens(debug.LEVEL_INFO, tokens, True)
--
2.50.0