From: joncruz Date: Mon, 29 May 2006 16:12:36 +0000 (+0000) Subject: workaround assertion upon file revert X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=362d6fa90bf1d5218f2bb4f72ce194e074778a25;p=inkscape.git workaround assertion upon file revert --- diff --git a/ChangeLog b/ChangeLog index f9a908f01..4a6b28a80 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-05-29 Jon A. Cruz + + * src/desktop.cpp, src/layer-manager.cpp, src/dialogs/layers-panel.cpp: + Workaround to avoid assertion upon file revert. + 2006-05-28 Bryce * sp-marker.cpp: Adding documentation @@ -37,7 +42,7 @@ 2006-05-28 Jon A. Cruz - * src/layer-manager.cpp, src/layer-manager.cpp, + * src/layer-manager.cpp, src/layer-manager.h, src/preferences-skeleton.h, src/ui/dialog/inkscape-preferences.cpp, src/ui/dialog/inkscape-preferences.h, src/widgets/layer-selector.cpp, src/dialogs/layers-panel.cpp: diff --git a/src/desktop.cpp b/src/desktop.cpp index b1dbae118..17ce0907c 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -380,7 +380,7 @@ SPObject *SPDesktop::currentLayer() const */ void SPDesktop::setCurrentLayer(SPObject *object) { g_return_if_fail(SP_IS_GROUP(object)); - g_return_if_fail( currentRoot() == object || currentRoot()->isAncestorOf(object)); + g_return_if_fail( currentRoot() == object || (currentRoot() && currentRoot()->isAncestorOf(object)) ); // printf("Set Layer to ID: %s\n", SP_OBJECT_ID(object)); _layer_hierarchy->setBottom(object); } diff --git a/src/dialogs/layers-panel.cpp b/src/dialogs/layers-panel.cpp index cdcafbbc1..a09ce1527 100644 --- a/src/dialogs/layers-panel.cpp +++ b/src/dialogs/layers-panel.cpp @@ -499,13 +499,16 @@ SPObject* LayersPanel::_selectedLayer() void LayersPanel::_pushTreeSelectionToCurrent() { SPObject* inTree = _selectedLayer(); - if ( inTree ) { - SPObject* curr = _desktop->currentLayer(); - if ( curr != inTree ) { - _mgr->setCurrentLayer( inTree ); + // TODO hunt down the possible API abuse in getting NULL + if ( _desktop->currentRoot() ) { + if ( inTree ) { + SPObject* curr = _desktop->currentLayer(); + if ( curr != inTree ) { + _mgr->setCurrentLayer( inTree ); + } + } else { + _mgr->setCurrentLayer( _desktop->doc()->root ); } - } else { - _mgr->setCurrentLayer( _desktop->doc()->root ); } } diff --git a/src/layer-manager.cpp b/src/layer-manager.cpp index e2e40340f..61b0e15bb 100644 --- a/src/layer-manager.cpp +++ b/src/layer-manager.cpp @@ -75,10 +75,13 @@ LayerManager::LayerManager(SPDesktop *desktop) void LayerManager::setCurrentLayer( SPObject* obj ) { - _desktop->setCurrentLayer( obj ); + //g_return_if_fail( _desktop->currentRoot() ); + if ( _desktop->currentRoot() ) { + _desktop->setCurrentLayer( obj ); - if ( prefs_get_int_attribute_limited("options.selection", "layerdeselect", 1, 0, 1) ) { - sp_desktop_selection( _desktop )->clear(); + if ( prefs_get_int_attribute_limited("options.selection", "layerdeselect", 1, 0, 1) ) { + sp_desktop_selection( _desktop )->clear(); + } } }