Fix finalization.
This commit is contained in:
		@ -123,11 +123,7 @@ static void
 | 
				
			|||||||
eek_clutter_key_actor_finalize (GObject *object)
 | 
					eek_clutter_key_actor_finalize (GObject *object)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    EekClutterKeyActorPrivate *priv = EEK_CLUTTER_KEY_ACTOR_GET_PRIVATE(object);
 | 
					    EekClutterKeyActorPrivate *priv = EEK_CLUTTER_KEY_ACTOR_GET_PRIVATE(object);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    clutter_group_remove_all (CLUTTER_GROUP(object));
 | 
					 | 
				
			||||||
    g_object_unref (priv->key);
 | 
					    g_object_unref (priv->key);
 | 
				
			||||||
       if (priv->texture)
 | 
					 | 
				
			||||||
           g_object_unref (priv->texture);
 | 
					 | 
				
			||||||
    G_OBJECT_CLASS (eek_clutter_key_actor_parent_class)->finalize (object);
 | 
					    G_OBJECT_CLASS (eek_clutter_key_actor_parent_class)->finalize (object);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -140,11 +136,6 @@ eek_clutter_key_actor_class_init (EekClutterKeyActorClass *klass)
 | 
				
			|||||||
    g_type_class_add_private (gobject_class,
 | 
					    g_type_class_add_private (gobject_class,
 | 
				
			||||||
                              sizeof (EekClutterKeyActorPrivate));
 | 
					                              sizeof (EekClutterKeyActorPrivate));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    klass->outline_textures = g_hash_table_new_full (g_direct_hash,
 | 
					 | 
				
			||||||
                                                     g_direct_equal,
 | 
					 | 
				
			||||||
                                                     NULL,
 | 
					 | 
				
			||||||
                                                     g_free);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    actor_class->paint = eek_clutter_key_actor_real_paint;
 | 
					    actor_class->paint = eek_clutter_key_actor_real_paint;
 | 
				
			||||||
    /* FIXME: This is a workaround for the bug
 | 
					    /* FIXME: This is a workaround for the bug
 | 
				
			||||||
     * http://bugzilla.openedhand.com/show_bug.cgi?id=2137 A developer
 | 
					     * http://bugzilla.openedhand.com/show_bug.cgi?id=2137 A developer
 | 
				
			||||||
@ -488,18 +479,21 @@ create_texture_for_key (EekKey *key)
 | 
				
			|||||||
static ClutterActor *
 | 
					static ClutterActor *
 | 
				
			||||||
get_texture (EekClutterKeyActor *actor)
 | 
					get_texture (EekClutterKeyActor *actor)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    EekClutterKeyActorClass *actor_class =
 | 
				
			||||||
 | 
					        EEK_CLUTTER_KEY_ACTOR_GET_CLASS(actor);
 | 
				
			||||||
    ClutterActor *texture;
 | 
					    ClutterActor *texture;
 | 
				
			||||||
    GHashTable *outline_textures;
 | 
					 | 
				
			||||||
    EekOutline *outline;
 | 
					    EekOutline *outline;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    outline_textures = EEK_CLUTTER_KEY_ACTOR_GET_CLASS(actor)->
 | 
					    if (!actor_class->outline_textures)
 | 
				
			||||||
        outline_textures;
 | 
					        actor_class->outline_textures = g_hash_table_new_full (g_direct_hash,
 | 
				
			||||||
 | 
					                                                               g_direct_equal,
 | 
				
			||||||
 | 
					                                                               NULL,
 | 
				
			||||||
 | 
					                                                               g_free);
 | 
				
			||||||
    outline = eek_key_get_outline (actor->priv->key);
 | 
					    outline = eek_key_get_outline (actor->priv->key);
 | 
				
			||||||
    texture = g_hash_table_lookup (outline_textures, outline);
 | 
					    texture = g_hash_table_lookup (actor_class->outline_textures, outline);
 | 
				
			||||||
    if (texture == NULL) {
 | 
					    if (texture == NULL) {
 | 
				
			||||||
        texture = create_texture_for_key (actor->priv->key);
 | 
					        texture = create_texture_for_key (actor->priv->key);
 | 
				
			||||||
        g_hash_table_insert (outline_textures, outline, texture);
 | 
					        g_hash_table_insert (actor_class->outline_textures, outline, texture);
 | 
				
			||||||
    } else
 | 
					    } else
 | 
				
			||||||
        texture = clutter_clone_new (texture);
 | 
					        texture = clutter_clone_new (texture);
 | 
				
			||||||
    return texture;
 | 
					    return texture;
 | 
				
			||||||
 | 
				
			|||||||
@ -73,10 +73,10 @@ eek_clutter_key_finalize (GObject *object)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(object);
 | 
					    EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(object);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (priv->actor) {
 | 
					    /* No need for clutter_group_remove_all() since
 | 
				
			||||||
        clutter_group_remove_all (CLUTTER_GROUP(priv->actor));
 | 
					       ClutterGroup#dispose() unrefs all the children. */
 | 
				
			||||||
 | 
					    if (priv->actor)
 | 
				
			||||||
        g_object_unref (priv->actor);
 | 
					        g_object_unref (priv->actor);
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    G_OBJECT_CLASS (eek_clutter_key_parent_class)->finalize (object);
 | 
					    G_OBJECT_CLASS (eek_clutter_key_parent_class)->finalize (object);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -40,6 +40,7 @@ G_DEFINE_TYPE (EekClutterKeyboard, eek_clutter_keyboard, EEK_TYPE_KEYBOARD);
 | 
				
			|||||||
struct _EekClutterKeyboardPrivate
 | 
					struct _EekClutterKeyboardPrivate
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    ClutterActor *actor;
 | 
					    ClutterActor *actor;
 | 
				
			||||||
 | 
					    EekLayout *layout;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
@ -97,8 +98,10 @@ eek_clutter_keyboard_real_create_section (EekKeyboard *self)
 | 
				
			|||||||
    g_return_val_if_fail (section, NULL);
 | 
					    g_return_val_if_fail (section, NULL);
 | 
				
			||||||
    g_object_ref_sink (section);
 | 
					    g_object_ref_sink (section);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    g_signal_connect (section, "key-pressed", G_CALLBACK(key_pressed_event), self);
 | 
					    g_signal_connect (section, "key-pressed",
 | 
				
			||||||
    g_signal_connect (section, "key-released", G_CALLBACK(key_released_event), self);
 | 
					                      G_CALLBACK(key_pressed_event), self);
 | 
				
			||||||
 | 
					    g_signal_connect (section, "key-released",
 | 
				
			||||||
 | 
					                      G_CALLBACK(key_released_event), self);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    EEK_CONTAINER_GET_CLASS(self)->add_child (EEK_CONTAINER(self),
 | 
					    EEK_CONTAINER_GET_CLASS(self)->add_child (EEK_CONTAINER(self),
 | 
				
			||||||
                                              EEK_ELEMENT(section));
 | 
					                                              EEK_ELEMENT(section));
 | 
				
			||||||
@ -111,15 +114,31 @@ eek_clutter_keyboard_real_create_section (EekKeyboard *self)
 | 
				
			|||||||
    return section;
 | 
					    return section;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					eek_clutter_keyboard_real_set_layout (EekKeyboard *self,
 | 
				
			||||||
 | 
					                                      EekLayout   *layout)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    EekClutterKeyboardPrivate *priv = EEK_CLUTTER_KEYBOARD_GET_PRIVATE(self);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    g_return_if_fail (EEK_IS_LAYOUT(layout));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* Don't apply the layout to keyboard right now, so to delay
 | 
				
			||||||
 | 
					       drawing until eek_clutter_keyboard_get_actor. */
 | 
				
			||||||
 | 
					    priv->layout = layout;
 | 
				
			||||||
 | 
					    g_object_ref_sink (priv->layout);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
eek_clutter_keyboard_finalize (GObject *object)
 | 
					eek_clutter_keyboard_finalize (GObject *object)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    EekClutterKeyboardPrivate *priv = EEK_CLUTTER_KEYBOARD_GET_PRIVATE(object);
 | 
					    EekClutterKeyboardPrivate *priv = EEK_CLUTTER_KEYBOARD_GET_PRIVATE(object);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (priv->actor) {
 | 
					    /* No need for clutter_group_remove_all() since
 | 
				
			||||||
        clutter_group_remove_all (CLUTTER_GROUP(priv->actor));
 | 
					       ClutterGroup#dispose() unrefs all the children. */
 | 
				
			||||||
 | 
					    if (priv->actor)
 | 
				
			||||||
        g_object_unref (priv->actor);
 | 
					        g_object_unref (priv->actor);
 | 
				
			||||||
    }
 | 
					    if (priv->layout)
 | 
				
			||||||
 | 
					        g_object_unref (priv->layout);
 | 
				
			||||||
    G_OBJECT_CLASS (eek_clutter_keyboard_parent_class)->finalize (object);
 | 
					    G_OBJECT_CLASS (eek_clutter_keyboard_parent_class)->finalize (object);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -146,6 +165,7 @@ eek_clutter_keyboard_init (EekClutterKeyboard *self)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    priv = self->priv = EEK_CLUTTER_KEYBOARD_GET_PRIVATE(self);
 | 
					    priv = self->priv = EEK_CLUTTER_KEYBOARD_GET_PRIVATE(self);
 | 
				
			||||||
    priv->actor = NULL;
 | 
					    priv->actor = NULL;
 | 
				
			||||||
 | 
					    priv->layout = NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@ -182,5 +202,7 @@ eek_clutter_keyboard_get_actor (EekClutterKeyboard *keyboard)
 | 
				
			|||||||
        EEK_CLUTTER_KEYBOARD_GET_PRIVATE(keyboard);
 | 
					        EEK_CLUTTER_KEYBOARD_GET_PRIVATE(keyboard);
 | 
				
			||||||
    if (!priv->actor)
 | 
					    if (!priv->actor)
 | 
				
			||||||
        priv->actor = clutter_group_new ();
 | 
					        priv->actor = clutter_group_new ();
 | 
				
			||||||
 | 
					    if (priv->layout)
 | 
				
			||||||
 | 
					        eek_layout_apply (priv->layout, EEK_KEYBOARD(keyboard));
 | 
				
			||||||
    return priv->actor;
 | 
					    return priv->actor;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -137,10 +137,10 @@ eek_clutter_section_finalize (GObject *object)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    EekClutterSectionPrivate *priv = EEK_CLUTTER_SECTION_GET_PRIVATE(object);
 | 
					    EekClutterSectionPrivate *priv = EEK_CLUTTER_SECTION_GET_PRIVATE(object);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (priv->actor) {
 | 
					    /* No need for clutter_group_remove_all() since
 | 
				
			||||||
        clutter_group_remove_all (CLUTTER_GROUP(priv->actor));
 | 
					       ClutterGroup#dispose() unrefs all the children. */
 | 
				
			||||||
 | 
					    if (priv->actor)
 | 
				
			||||||
        g_object_unref (priv->actor);
 | 
					        g_object_unref (priv->actor);
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    G_OBJECT_CLASS (eek_clutter_section_parent_class)->finalize (object);
 | 
					    G_OBJECT_CLASS (eek_clutter_section_parent_class)->finalize (object);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -143,8 +143,10 @@ eek_keyboard_real_create_section (EekKeyboard *self)
 | 
				
			|||||||
    g_return_val_if_fail (section, NULL);
 | 
					    g_return_val_if_fail (section, NULL);
 | 
				
			||||||
    g_object_ref_sink (section);
 | 
					    g_object_ref_sink (section);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    g_signal_connect (section, "key-pressed", G_CALLBACK(key_pressed_event), self);
 | 
					    g_signal_connect (section, "key-pressed",
 | 
				
			||||||
    g_signal_connect (section, "key-released", G_CALLBACK(key_released_event), self);
 | 
					                      G_CALLBACK(key_pressed_event), self);
 | 
				
			||||||
 | 
					    g_signal_connect (section, "key-released",
 | 
				
			||||||
 | 
					                      G_CALLBACK(key_released_event), self);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    EEK_CONTAINER_GET_CLASS(self)->add_child (EEK_CONTAINER(self),
 | 
					    EEK_CONTAINER_GET_CLASS(self)->add_child (EEK_CONTAINER(self),
 | 
				
			||||||
                                              EEK_ELEMENT(section));
 | 
					                                              EEK_ELEMENT(section));
 | 
				
			||||||
@ -152,12 +154,12 @@ eek_keyboard_real_create_section (EekKeyboard *self)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
eek_keyboard_real_set_layout (EekKeyboard *keyboard,
 | 
					eek_keyboard_real_set_layout (EekKeyboard *self,
 | 
				
			||||||
                              EekLayout   *layout)
 | 
					                              EekLayout   *layout)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    g_return_if_fail (EEK_IS_LAYOUT(layout));
 | 
					    g_return_if_fail (EEK_IS_LAYOUT(layout));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    EEK_LAYOUT_GET_IFACE(layout)->apply (layout, keyboard);
 | 
					    EEK_LAYOUT_GET_IFACE(layout)->apply (layout, self);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (g_object_is_floating (layout))
 | 
					    if (g_object_is_floating (layout))
 | 
				
			||||||
        g_object_unref (layout);
 | 
					        g_object_unref (layout);
 | 
				
			||||||
 | 
				
			|||||||
@ -305,9 +305,6 @@ eek_xkb_layout_real_apply (EekLayout *layout, EekKeyboard *keyboard)
 | 
				
			|||||||
    g_return_if_fail (EEK_IS_KEYBOARD(keyboard));
 | 
					    g_return_if_fail (EEK_IS_KEYBOARD(keyboard));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    create_keyboard (EEK_XKB_LAYOUT(layout), keyboard);
 | 
					    create_keyboard (EEK_XKB_LAYOUT(layout), keyboard);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (g_object_is_floating (keyboard))
 | 
					 | 
				
			||||||
        g_object_unref (keyboard);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
@ -318,8 +315,7 @@ eek_xkb_layout_finalize (GObject *object)
 | 
				
			|||||||
    g_free (priv->names.keycodes);
 | 
					    g_free (priv->names.keycodes);
 | 
				
			||||||
    g_free (priv->names.geometry);
 | 
					    g_free (priv->names.geometry);
 | 
				
			||||||
    g_free (priv->names.symbols);
 | 
					    g_free (priv->names.symbols);
 | 
				
			||||||
    /* XXX */
 | 
					    g_hash_table_unref (priv->outline_hash);
 | 
				
			||||||
    //g_hash_table_unref (priv->outline_hash);
 | 
					 | 
				
			||||||
    XkbFreeKeyboard (priv->xkb, 0, TRUE);	/* free_all = TRUE */
 | 
					    XkbFreeKeyboard (priv->xkb, 0, TRUE);	/* free_all = TRUE */
 | 
				
			||||||
    G_OBJECT_CLASS (eek_xkb_layout_parent_class)->finalize (object);
 | 
					    G_OBJECT_CLASS (eek_xkb_layout_parent_class)->finalize (object);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user