diff options
author | Juan Pablo Ugarte <juanpablougarte@gmail.com> | 2013-01-22 15:10:05 -0300 |
---|---|---|
committer | Juan Pablo Ugarte <juanpablougarte@gmail.com> | 2013-01-22 15:11:06 -0300 |
commit | e39468657cb7ffc03bc3235350c181cf4a927bec (patch) | |
tree | bd26f5ff266778fc5a1cad97b2a91f31fd7ce28d /gladeui/glade-design-view.c | |
parent | 58a24648598af1df361ce3478af3c5a76defab65 (diff) | |
download | glade-e39468657cb7ffc03bc3235350c181cf4a927bec.tar.gz |
glade_design_view_set_project(): keep a reference to project
Diffstat (limited to 'gladeui/glade-design-view.c')
-rw-r--r-- | gladeui/glade-design-view.c | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/gladeui/glade-design-view.c b/gladeui/glade-design-view.c index fa931429..a192e1cc 100644 --- a/gladeui/glade-design-view.c +++ b/gladeui/glade-design-view.c @@ -212,9 +212,38 @@ on_project_remove_widget (GladeProject *project, GladeWidget *widget, GladeDesig static void glade_design_view_set_project (GladeDesignView *view, GladeProject *project) { + GladeDesignViewPrivate *priv; + g_return_if_fail (GLADE_IS_PROJECT (project)); - view->priv->project = project; + priv = view->priv; + + if (priv->project) + { + g_signal_handlers_disconnect_by_func (priv->project, + on_project_add_widget, + view); + g_signal_handlers_disconnect_by_func (priv->project, + on_project_remove_widget, + view); + g_signal_handlers_disconnect_by_func (priv->project, + gtk_widget_hide, + priv->scrolled_window); + g_signal_handlers_disconnect_by_func (priv->project, + gtk_widget_show, + priv->scrolled_window); + g_signal_handlers_disconnect_by_func (priv->project, + glade_design_view_selection_changed, + view); + g_signal_handlers_disconnect_by_func (priv->project, + glade_design_view_widget_visibility_changed, + view); + + g_object_set_data (G_OBJECT (priv->project), GLADE_DESIGN_VIEW_KEY, NULL); + g_object_unref (priv->project); + } + + view->priv->project = g_object_ref (project); g_signal_connect (project, "add-widget", G_CALLBACK (on_project_add_widget), view); @@ -222,10 +251,10 @@ glade_design_view_set_project (GladeDesignView *view, GladeProject *project) G_CALLBACK (on_project_remove_widget), view); g_signal_connect_swapped (project, "parse-began", G_CALLBACK (gtk_widget_hide), - view->priv->scrolled_window); + priv->scrolled_window); g_signal_connect_swapped (project, "parse-finished", G_CALLBACK (gtk_widget_show), - view->priv->scrolled_window); + priv->scrolled_window); g_signal_connect (project, "selection-changed", G_CALLBACK (glade_design_view_selection_changed), view); g_signal_connect (project, "widget-visibility-changed", @@ -365,11 +394,8 @@ static void glade_design_view_finalize (GObject *object) { GladeDesignView *view = GLADE_DESIGN_VIEW (object); - GladeDesignViewPrivate *priv = view->priv; - /* Yup, disconnect every handler that reference this view */ - g_signal_handlers_disconnect_by_data (priv->project, view); - g_signal_handlers_disconnect_by_data (priv->project, priv->scrolled_window); + glade_design_view_set_project (view, NULL); G_OBJECT_CLASS (parent_class)->finalize (object); } |