Replace the autorelease pools used for each drawing context and in
2007-12-10 Richard Hult <richard@imendio.com> * gdk/quartz/gdkdrawable-quartz.c: (gdk_quartz_drawable_get_context), (gdk_quartz_drawable_release_context): * gdk/quartz/gdkeventloop-quartz.c: (gdk_event_prepare), (gdk_event_check), (gdk_event_dispatch), (poll_func): * gdk/quartz/gdkwindow-quartz.h: Replace the autorelease pools used for each drawing context and in prepare, dispatch and poll with one that exists across each main loop iteration. Fixes leaks on leopard and protects against future leaks introduce when the underlying system changes again (bug #492977). svn path=/trunk/; revision=19149
This commit is contained in:
committed by
Richard Hult
parent
f4baa51f49
commit
d7f3ab0569
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
||||
2007-12-10 Richard Hult <richard@imendio.com>
|
||||
|
||||
* gdk/quartz/gdkdrawable-quartz.c:
|
||||
(gdk_quartz_drawable_get_context),
|
||||
(gdk_quartz_drawable_release_context):
|
||||
* gdk/quartz/gdkeventloop-quartz.c: (gdk_event_prepare),
|
||||
(gdk_event_check), (gdk_event_dispatch), (poll_func):
|
||||
* gdk/quartz/gdkwindow-quartz.h: Replace the autorelease pools
|
||||
used for each drawing context and in prepare, dispatch and poll
|
||||
with one that exists across each main loop iteration. Fixes leaks
|
||||
on leopard and protects against future leaks introduce when the
|
||||
underlying system changes again (bug #492977).
|
||||
|
||||
2007-12-10 Richard Hult <richard@imendio.com>
|
||||
|
||||
* gdk/quartz/gdkwindow-quartz.c: (move_resize_window_internal):
|
||||
|
||||
@ -687,15 +687,9 @@ gdk_quartz_drawable_get_context (GdkDrawable *drawable,
|
||||
*/
|
||||
if (window_impl->in_paint_rect_count == 0)
|
||||
{
|
||||
window_impl->pool = [[NSAutoreleasePool alloc] init];
|
||||
if (![window_impl->view lockFocusIfCanDraw])
|
||||
{
|
||||
[window_impl->pool release];
|
||||
window_impl->pool = NULL;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
cg_context = [[NSGraphicsContext currentContext] graphicsPort];
|
||||
CGContextSaveGState (cg_context);
|
||||
@ -767,15 +761,7 @@ gdk_quartz_drawable_release_context (GdkDrawable *drawable,
|
||||
|
||||
/* See comment in gdk_quartz_drawable_get_context(). */
|
||||
if (window_impl->in_paint_rect_count == 0)
|
||||
{
|
||||
[window_impl->view unlockFocus];
|
||||
|
||||
if (window_impl->pool)
|
||||
{
|
||||
[window_impl->pool release];
|
||||
window_impl->pool = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (GDK_IS_PIXMAP_IMPL_QUARTZ (drawable))
|
||||
CGContextRelease (cg_context);
|
||||
|
||||
@ -23,6 +23,7 @@ static GPollFD *pipe_pollfd;
|
||||
static guint n_pollfds;
|
||||
static CFRunLoopSourceRef select_main_thread_source;
|
||||
static CFRunLoopRef main_thread_run_loop;
|
||||
static NSAutoreleasePool *autorelease_pool;
|
||||
|
||||
gboolean
|
||||
_gdk_quartz_event_loop_check_pending (void)
|
||||
@ -56,8 +57,6 @@ gdk_event_prepare (GSource *source,
|
||||
|
||||
GDK_THREADS_ENTER ();
|
||||
|
||||
GDK_QUARTZ_ALLOC_POOL;
|
||||
|
||||
*timeout = -1;
|
||||
|
||||
event = [NSApp nextEventMatchingMask: NSAnyEventMask
|
||||
@ -68,8 +67,6 @@ gdk_event_prepare (GSource *source,
|
||||
retval = (_gdk_event_queue_find_first (_gdk_display) != NULL ||
|
||||
event != NULL);
|
||||
|
||||
GDK_QUARTZ_RELEASE_POOL;
|
||||
|
||||
GDK_THREADS_LEAVE ();
|
||||
|
||||
return retval;
|
||||
@ -82,6 +79,10 @@ gdk_event_check (GSource *source)
|
||||
|
||||
GDK_THREADS_ENTER ();
|
||||
|
||||
if (autorelease_pool)
|
||||
[autorelease_pool release];
|
||||
autorelease_pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
if (_gdk_event_queue_find_first (_gdk_display) != NULL ||
|
||||
_gdk_quartz_event_loop_check_pending ())
|
||||
retval = TRUE;
|
||||
@ -102,8 +103,6 @@ gdk_event_dispatch (GSource *source,
|
||||
|
||||
GDK_THREADS_ENTER ();
|
||||
|
||||
GDK_QUARTZ_ALLOC_POOL;
|
||||
|
||||
_gdk_events_queue (_gdk_display);
|
||||
|
||||
event = _gdk_event_unqueue (_gdk_display);
|
||||
@ -116,8 +115,6 @@ gdk_event_dispatch (GSource *source,
|
||||
gdk_event_free (event);
|
||||
}
|
||||
|
||||
GDK_QUARTZ_RELEASE_POOL;
|
||||
|
||||
GDK_THREADS_LEAVE ();
|
||||
|
||||
return TRUE;
|
||||
@ -201,8 +198,6 @@ poll_func (GPollFD *ufds, guint nfds, gint timeout_)
|
||||
int n_active = 0;
|
||||
int i;
|
||||
|
||||
GDK_QUARTZ_ALLOC_POOL;
|
||||
|
||||
if (nfds > 1)
|
||||
{
|
||||
if (!select_thread) {
|
||||
@ -306,8 +301,6 @@ poll_func (GPollFD *ufds, guint nfds, gint timeout_)
|
||||
n_active ++;
|
||||
}
|
||||
|
||||
GDK_QUARTZ_RELEASE_POOL;
|
||||
|
||||
return n_active;
|
||||
}
|
||||
|
||||
@ -328,5 +321,6 @@ _gdk_quartz_event_loop_init (void)
|
||||
old_poll_func = g_main_context_get_poll_func (NULL);
|
||||
g_main_context_set_poll_func (NULL, poll_func);
|
||||
|
||||
autorelease_pool = [[NSAutoreleasePool alloc] init];
|
||||
}
|
||||
|
||||
|
||||
@ -54,11 +54,6 @@ struct _GdkWindowImplQuartz
|
||||
|
||||
GdkWindowTypeHint type_hint;
|
||||
|
||||
/* This is the autorelease pool which is retained
|
||||
* while the context is being held
|
||||
*/
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
NSCursor *nscursor;
|
||||
|
||||
GdkRegion *paint_clip_region;
|
||||
|
||||
Reference in New Issue
Block a user