diff --git a/ChangeLog b/ChangeLog index e7de56961..163388329 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-12-18 Øyvind Kolås + + * clutter/clutter-main.c: (generate_enter_leave_events): synthesize + enter event (without related) and corresponding leave event when the + actor the cursor is over has been destroyed. + * clutter/clutter-event.c: (clutter_event_free): only unref the + related_actor when it actually is set. + 2007-12-18 Emmanuele Bassi * clutter/clutter-main.c: diff --git a/clutter/clutter-event.c b/clutter/clutter-event.c index 1ab98faa3..34cc45bd7 100644 --- a/clutter/clutter-event.c +++ b/clutter/clutter-event.c @@ -355,8 +355,9 @@ clutter_event_free (ClutterEvent *event) { if (G_LIKELY (event)) { - if (event->type == CLUTTER_LEAVE || event->type == CLUTTER_ENTER) - g_object_unref (event->crossing.related); + if ((event->type == CLUTTER_LEAVE || event->type == CLUTTER_ENTER) && + event->crossing.related) + g_object_unref (event->crossing.related); g_slice_free (ClutterEvent, event); } } diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index 97cda3b7d..2f2d77d56 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -1272,21 +1272,24 @@ generate_enter_leave_events (ClutterEvent *event) if (context->motion_last_actor != motion_current_actor) { - if (context->motion_last_actor && motion_current_actor) + if (motion_current_actor) { ClutterEvent cev; - cev.crossing.type = CLUTTER_LEAVE; - cev.crossing.time = event->any.time; - cev.crossing.flags = 0; - cev.crossing.x = event->motion.x; - cev.crossing.y = event->motion.y; - cev.crossing.source = context->motion_last_actor; - /* unref in free */ - cev.crossing.related = g_object_ref (motion_current_actor); + if (context->motion_last_actor) + { + cev.crossing.type = CLUTTER_LEAVE; + cev.crossing.time = event->any.time; + cev.crossing.flags = 0; + cev.crossing.x = event->motion.x; + cev.crossing.y = event->motion.y; + cev.crossing.source = context->motion_last_actor; + /* unref in free */ + cev.crossing.related = g_object_ref (motion_current_actor); - g_queue_push_head (context->events_queue, - clutter_event_copy (&cev)); + g_queue_push_head (context->events_queue, + clutter_event_copy (&cev)); + } cev.crossing.type = CLUTTER_ENTER; cev.crossing.time = event->any.time; @@ -1294,7 +1297,17 @@ generate_enter_leave_events (ClutterEvent *event) cev.crossing.x = event->motion.x; cev.crossing.y = event->motion.y; cev.crossing.source = motion_current_actor; - cev.crossing.related = g_object_ref (context->motion_last_actor); + if (context->motion_last_actor) + { + cev.crossing.related = g_object_ref (context->motion_last_actor); + } + else + { + /* the previous actor we were getting events from seems to have + * vanished + */ + cev.crossing.related = NULL; + } g_queue_push_head (context->events_queue, clutter_event_copy (&cev));