[gtk+/gtk-2-24] Bug 701571 NSApp doesn't notice NSWindow destruction
- From: John Ralls <jralls src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-2-24] Bug 701571 NSApp doesn't notice NSWindow destruction
- Date: Sun, 11 Aug 2013 18:02:26 +0000 (UTC)
commit 49fd2b2b469c5edfc741099070a31d0b79014857
Author: John Ralls <jralls ceridwen us>
Date: Sat Aug 10 14:11:49 2013 -0700
Bug 701571 NSApp doesn't notice NSWindow destruction
Part 1 of the fix; part 2 awaits Glib developer approval (see
https://bugzilla.gnome.org/show_bug.cgi?id=704374) and is more
correctly associated with
https://bugzilla.gnome.org/show_bug.cgi?id=674108
gdk/quartz/gdkeventloop-quartz.c | 42 +++++++++++++++++++++++--------------
1 files changed, 26 insertions(+), 16 deletions(-)
---
diff --git a/gdk/quartz/gdkeventloop-quartz.c b/gdk/quartz/gdkeventloop-quartz.c
index 224d84c..39c1f90 100644
--- a/gdk/quartz/gdkeventloop-quartz.c
+++ b/gdk/quartz/gdkeventloop-quartz.c
@@ -617,7 +617,32 @@ gdk_event_prepare (GSource *source,
gboolean retval;
GDK_THREADS_ENTER ();
-
+
+ /* The prepare stage is the stage before the main loop starts polling
+ * and dispatching events. The autorelease poll is drained here for
+ * the preceding main loop iteration or, in case of the first iteration,
+ * for the operations carried out between event loop initialization and
+ * this first iteration.
+ *
+ * The autorelease poll must only be drained when the following conditions
+ * apply:
+ * - We are at the base CFRunLoop level (indicated by current_loop_level),
+ * - We are at the base g_main_loop level (indicated by
+ * g_main_depth())
+ * - We are at the base poll_func level (indicated by getting events).
+ *
+ * Messing with the autorelease pool at any level of nesting can cause access
+ * to deallocated memory because autorelease_pool is static and releasing a
+ * pool will cause all pools allocated inside of it to be released as well.
+ */
+ if (current_loop_level == 0 && g_main_depth() == 0 && getting_events == 0)
+ {
+ if (autorelease_pool)
+ [autorelease_pool drain];
+
+ autorelease_pool = [[NSAutoreleasePool alloc] init];
+ }
+
*timeout = -1;
retval = (_gdk_event_queue_find_first (_gdk_display) != NULL ||
@@ -652,21 +677,6 @@ gdk_event_dispatch (GSource *source,
GDK_THREADS_ENTER ();
- /* Refresh the autorelease pool if we're at the base CFRunLoop level
- * (indicated by current_loop_level) and the base g_main_loop level
- * (indicated by g_main_depth()). Messing with the autorelease pool at
- * any level of nesting can cause access to deallocated memory because
- * autorelease_pool is static and releasing a pool will cause all pools
- * allocated inside of it to be released as well.
- */
- if (current_loop_level == 0 && g_main_depth() == 0)
- {
- if (autorelease_pool)
- [autorelease_pool drain];
-
- autorelease_pool = [[NSAutoreleasePool alloc] init];
- }
-
_gdk_events_queue (_gdk_display);
event = _gdk_event_unqueue (_gdk_display);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]