Commit a6b0ccb9 authored by Tristan Van Berkom's avatar Tristan Van Berkom
Browse files

* gladeui/glade-project.c: Cleanup glade_project_remove_object(), make sure row_deleted is

	  fired before modifying internal data structures (and dont use the glade_util_ function
	  to find a widget iter).
parent bf924d1b
......@@ -2997,6 +2997,7 @@ glade_project_has_object (GladeProject *project, GObject *object)
}
GladeWidget *project_debug_widget;
/**
* glade_project_remove_object:
* @project: a #GladeProject
......@@ -3012,9 +3013,9 @@ void
glade_project_remove_object (GladeProject *project, GObject *object)
{
GladeWidget *gwidget;
GList *list, *children;
GtkTreeIter* iter;
GtkTreePath* path;
GList *list, *children, *link;
GtkTreeIter iter;
GtkTreePath *path;
g_return_if_fail (GLADE_IS_PROJECT (project));
g_return_if_fail (G_IS_OBJECT (object));
......@@ -3024,7 +3025,10 @@ glade_project_remove_object (GladeProject *project, GObject *object)
if ((gwidget = glade_widget_get_from_gobject (object)) == NULL)
return;
project_debug_widget = gwidget;
/* Recurse and remove deepest children first */
if ((children =
glade_widget_get_children (gwidget)) != NULL)
{
......@@ -3032,38 +3036,35 @@ glade_project_remove_object (GladeProject *project, GObject *object)
glade_project_remove_object (project, G_OBJECT (list->data));
g_list_free (children);
}
/* Notify views that the row is being deleted *before* deleting it */
glade_project_model_get_iter_for_object (project, object, &iter);
path = gtk_tree_model_get_path (GTK_TREE_MODEL (project), &iter);
gtk_tree_model_row_deleted (GTK_TREE_MODEL (project), path);
gtk_tree_path_free (path);
/* Remove selection and release name from the name context */
glade_project_selection_remove (project, object, TRUE);
glade_project_release_widget_name (project, gwidget,
glade_widget_get_name (gwidget));
project->priv->objects = g_list_remove (project->priv->objects, object);
iter = glade_util_find_iter_by_widget (GTK_TREE_MODEL (project), gwidget,
GLADE_PROJECT_MODEL_COLUMN_OBJECT);
if (iter)
g_signal_emit (G_OBJECT (project),
glade_project_signals [REMOVE_WIDGET],
0,
gwidget);
/* Update internal data structure (remove from lists) */
link = g_list_find (project->priv->tree, object);
if (link)
{
GList *link = g_list_find (project->priv->tree, object);
project->priv->tree = g_list_delete_link (project->priv->tree, link);
}
path = gtk_tree_model_get_path (GTK_TREE_MODEL (project),
iter);
gtk_tree_model_row_deleted (GTK_TREE_MODEL (project),
path);
project->priv->stamp++;
g_object_unref (object);
glade_project_release_widget_name (project, gwidget,
glade_widget_get_name (gwidget));
project->priv->objects = g_list_remove (project->priv->objects, object);
g_object_unref (object);
if (link)
{
project->priv->tree = g_list_delete_link (project->priv->tree, link);
}
g_signal_emit (G_OBJECT (project),
glade_project_signals [REMOVE_WIDGET],
0,
gwidget);
gtk_tree_iter_free (iter);
}
project->priv->stamp++;
glade_project_update_previewable (project);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment