From 71c91912946e1e9cd94641e12e426ea0caf9a6eb Mon Sep 17 00:00:00 2001 From: johanengelen Date: Thu, 17 Jan 2008 20:50:00 +0000 Subject: [PATCH] remove SPDesktop from SPNamedView when it is destroyed. Fixing bug 183621, but another bug is apparently present that causes a bug with similar trigger --- src/desktop.cpp | 10 +++++++--- src/sp-namedview.cpp | 15 ++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/desktop.cpp b/src/desktop.cpp index e52d2b50c..9498d5399 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -314,6 +314,8 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas) void SPDesktop::destroy() { + namedview->hide(this); + _activate_connection.disconnect(); _deactivate_connection.disconnect(); _sel_modified_connection.disconnect(); @@ -1086,9 +1088,11 @@ SPDesktop::shutdown() bool SPDesktop::onDeleteUI (GdkEventAny*) { - if(shutdown()) return true; - destroyWidget(); - return false; + if(shutdown()) + return true; + + destroyWidget(); + return false; } /** diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 481f201cd..d26f00529 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -281,9 +281,9 @@ static void sp_namedview_release(SPObject *object) // delete grids: while ( namedview->grids ) { - Inkscape::CanvasGrid *gr = (Inkscape::CanvasGrid *)namedview->grids->data; + Inkscape::CanvasGrid *gr = (Inkscape::CanvasGrid *)namedview->grids->data; // get first entry delete gr; - namedview->grids = g_slist_remove_link(namedview->grids, namedview->grids); + namedview->grids = g_slist_remove_link(namedview->grids, namedview->grids); // deletes first entry } if (((SPObjectClass *) parent_class)->release) { @@ -575,6 +575,10 @@ sp_namedview_add_grid(SPNamedView *nv, Inkscape::XML::Node *repr, SPDesktop *des doc = sp_desktop_document(desktop); else doc = sp_desktop_document(static_cast(nv->views->data)); + if (!doc) { + g_warning("sp_namedview_add_grid - how come doc is null here?!"); + return NULL; + } grid = Inkscape::CanvasGrid::NewGrid(nv, repr, doc, gridtype); nv->grids = g_slist_append(nv->grids, grid); //Initialize the snapping parameters for the new grid @@ -833,13 +837,6 @@ void SPNamedView::hide(SPDesktop const *desktop) } views = g_slist_remove(views, desktop); - - // delete grids: - while ( grids ) { - Inkscape::CanvasGrid *gr = (Inkscape::CanvasGrid *)grids->data; - delete gr; - grids = g_slist_remove_link(grids, grids); - } } void SPNamedView::activateGuides(gpointer desktop, gboolean active) -- 2.30.2