Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Fix-1080409-StackOverflow-exception-opening-Gtk-host.patch « gtk « patches « packages - github.com/mono/bockbuild.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7b5d1c7975dee540fb1ca04f904e05259caf1301 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
From 588cba301ee3c43bdaebd41922b7bb60eb85c2ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Karlas=CC=8C?= <david.karlas@gmail.com>
Date: Thu, 14 May 2020 15:13:56 +0200
Subject: [PATCH] Fix 1080409: StackOverflow exception opening Gtk hosted
 NSView

Problem was that if `r.origin.x`/`r.origin.y` were 0, same value was looped until stackoverflow.
Whole logic of method assumes that it will loop over children hence recursive but in fact it kept passing same NSView over and over again...
---
 gdk/quartz/gdkevents-quartz.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/gdk/quartz/gdkevents-quartz.c b/gdk/quartz/gdkevents-quartz.c
index a12597d0f9..1734762e5c 100644
--- a/gdk/quartz/gdkevents-quartz.c
+++ b/gdk/quartz/gdkevents-quartz.c
@@ -729,9 +729,8 @@ _gdk_quartz_events_send_map_event (GdkWindow *window)
 }
 
 static NSView *
-find_nsview_at_pos (GdkWindowImplQuartz *impl, gint x, gint y)
+find_nsview_at_pos (NSView *view, NSView *layer_view, gint x, gint y)
 {
-  NSView *view = impl->view;
   guint n_subviews;
   guint i;
 
@@ -742,14 +741,14 @@ find_nsview_at_pos (GdkWindowImplQuartz *impl, gint x, gint y)
       NSView* sv = [[view subviews] objectAtIndex:i];
       NSRect r = [sv frame];
 
-      if (sv == impl->layer_view)
+      if (sv == layer_view)
         continue;
 
       if (![sv isHidden] &&
           r.origin.x <= x && r.origin.x + r.size.width >= x &&
           r.origin.y <= y && r.origin.y + r.size.height >= y)
         {
-          NSView* child = find_nsview_at_pos (impl, x - r.origin.x, y - r.origin.y);
+          NSView* child = find_nsview_at_pos (sv, layer_view, x - r.origin.x, y - r.origin.y);
           if (child != NULL)
             return child;
           else
@@ -933,7 +932,7 @@ find_window_for_ns_event (NSEvent *nsevent,
                 toplevel_private = (GdkWindowObject *)toplevel;
                 toplevel_impl = (GdkWindowImplQuartz *)toplevel_private->impl;
 
-                subview = find_nsview_at_pos (toplevel_impl, x_tmp, y_tmp);
+                subview = find_nsview_at_pos (toplevel_impl->view, toplevel_impl->layer_view, x_tmp, y_tmp);
                 if (subview != NULL && ![subview isKindOfClass:[GdkQuartzView class]]) {
                   g_signal_emit_by_name (toplevel, "native-child-event",
                                          subview, nsevent);
-- 
2.21.1 (Apple Git-122.3)