From eb102ab37f7113db39112726057ad7a474b7b2de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Sandmann?= Date: Thu, 30 Mar 2006 22:01:45 +0000 Subject: [PATCH] Fix the memory corruption in a better way. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thu Mar 30 17:01:12 2006 Søren Sandmann * src/compositor.c (struct MetaCompositor): Fix the memory corruption in a better way. --- ChangeLog | 5 ++++ src/compositor.c | 69 +++++++++++++++++++++++++++++++++--------------- 2 files changed, 52 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 530ea30c0..44b3bd6ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Mar 30 17:01:12 2006 Søren Sandmann + + * src/compositor.c (struct MetaCompositor): Fix the memory + corruption in a better way. + Thu Mar 30 16:38:35 2006 Søren Sandmann * src/compositor.c (meta_compositor_begin_move): Fix an illegal write. diff --git a/src/compositor.c b/src/compositor.c index b0361a3c9..e1dde075b 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -76,8 +76,6 @@ struct MetaCompositor guint debug_updates : 1; GList *ignored_damage; - - MoveInfo *move_info; }; #endif /* HAVE_COMPOSITE_EXTENSIONS */ @@ -1270,6 +1268,8 @@ get_patch_points (Model *model, } } +static GList *move_infos; + static gboolean wobble (gpointer data) { @@ -1286,9 +1286,12 @@ wobble (gpointer data) { if (!info->window_destroyed) meta_screen_info_unset_patch (minfo, get_xid (info->window)); + + move_infos = g_list_remove (move_infos, info); g_free (info); - info->compositor->move_info = NULL; +#if 0 g_print ("stop wobb\n"); +#endif return FALSE; } else @@ -1339,15 +1342,18 @@ meta_compositor_begin_move (MetaCompositor *compositor, { #ifdef HAVE_COMPOSITE_EXTENSIONS MetaRectangle rect; + MoveInfo *move_info; g_print ("begin move\n"); - compositor->move_info = g_new0 (MoveInfo, 1); + move_info = g_new0 (MoveInfo, 1); + + move_infos = g_list_prepend (move_infos, move_info); - compositor->move_info->compositor = compositor; - compositor->move_info->last_time = 0.0; - compositor->move_info->timer = g_timer_new (); - compositor->move_info->window_destroyed = FALSE; + move_info->compositor = compositor; + move_info->last_time = 0.0; + move_info->timer = g_timer_new (); + move_info->window_destroyed = FALSE; compute_window_rect (window, &rect); @@ -1358,23 +1364,43 @@ meta_compositor_begin_move (MetaCompositor *compositor, g_print ("grab: %d %d\n", grab_x, grab_y); #endif - compositor->move_info->model = model_new (&rect, TRUE); - compositor->move_info->window = window; - compositor->move_info->screen = window->screen; + move_info->model = model_new (&rect, TRUE); + move_info->window = window; + move_info->screen = window->screen; - model_begin_move (compositor->move_info->model, grab_x, grab_y); + model_begin_move (move_info->model, grab_x, grab_y); - g_idle_add (wobble, compositor->move_info); + g_idle_add (wobble, move_info); #endif } +#ifdef HAVE_COMPOSITE_EXTENSIONS +static MoveInfo * +find_info (MetaWindow *window) +{ + GList *list; + + for (list = move_infos; list != NULL; list = list->next) + { + MoveInfo *info = list->data; + + if (info->window == window) + return info; + } + + return NULL; +} +#endif + void meta_compositor_update_move (MetaCompositor *compositor, MetaWindow *window, int x, int y) { #ifdef HAVE_COMPOSITE_EXTENSIONS - model_update_move (compositor->move_info->model, x, y); + MoveInfo *move_info = find_info (window); + + model_update_move (move_info->model, x, y); #endif } @@ -1383,7 +1409,9 @@ meta_compositor_end_move (MetaCompositor *compositor, MetaWindow *window) { #ifdef HAVE_COMPOSITE_EXTENSIONS - compositor->move_info->finished = TRUE; + MoveInfo *info = find_info (window); + + info->finished = TRUE; #endif } @@ -1393,12 +1421,9 @@ meta_compositor_free_window (MetaCompositor *compositor, MetaWindow *window) { #ifdef HAVE_COMPOSITE_EXTENSIONS - g_print ("freeing\n"); - if (compositor->move_info) - { - g_print ("setting moveinfo to destroyed\n"); - compositor->move_info->window_destroyed = TRUE; - compositor->move_info = NULL; - } + MoveInfo *info = find_info (window); + + if (info) + info->window_destroyed = TRUE; #endif }