From 9e823fb7b754713611b4bb45032d0f11dabba196 Mon Sep 17 00:00:00 2001 From: tgdwyer Date: Fri, 16 Mar 2007 04:59:02 +0000 Subject: [PATCH] Added check for null bounding box of shapes involved in graph layout. I'm not actually sure if it's possible for something with a NULL item-box to be attached to a connector but if it is it's probably pretty safe to simply ignore. --- src/graphlayout/graphlayout.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/graphlayout/graphlayout.cpp b/src/graphlayout/graphlayout.cpp index 780532718..a111d7afe 100644 --- a/src/graphlayout/graphlayout.cpp +++ b/src/graphlayout/graphlayout.cpp @@ -94,12 +94,19 @@ void graphlayout(GSList const *const items) { { SPItem *u=*i; NR::Maybe const item_box(sp_item_bbox_desktop(u)); - g_assert(item_box); - NR::Point ll(item_box->min()); - NR::Point ur(item_box->max()); - nodelookup[u->id]=rs.size(); - rs.push_back(new Rectangle(ll[0]-spacing,ur[0]+spacing, - ll[1]-spacing,ur[1]+spacing)); + if(item_box) { + NR::Point ll(item_box->min()); + NR::Point ur(item_box->max()); + nodelookup[u->id]=rs.size(); + rs.push_back(new Rectangle(ll[0]-spacing,ur[0]+spacing, + ll[1]-spacing,ur[1]+spacing)); + } else { + // I'm not actually sure if it's possible for something with a + // NULL item-box to be attached to a connector in which case we + // should never get to here... but if such a null box can occur it's + // probably pretty safe to simply ignore + //fprintf(stderr,"NULL item_box found in graphlayout, ignoring!\n"); + } } SimpleConstraints scx,scy; @@ -190,10 +197,11 @@ void graphlayout(GSList const *const items) { if(!isConnector(u)) { Rectangle* r=rs[nodelookup[u->id]]; NR::Maybe item_box(sp_item_bbox_desktop(u)); - g_assert(item_box); - NR::Point const curr(item_box->midpoint()); - NR::Point const dest(r->getCentreX(),r->getCentreY()); - sp_item_move_rel(u, NR::translate(dest - curr)); + if(item_box) { + NR::Point const curr(item_box->midpoint()); + NR::Point const dest(r->getCentreX(),r->getCentreY()); + sp_item_move_rel(u, NR::translate(dest - curr)); + } } } for(unsigned i=0;i