Code

workaround assertion upon file revert
authorjoncruz <joncruz@users.sourceforge.net>
Mon, 29 May 2006 16:12:36 +0000 (16:12 +0000)
committerjoncruz <joncruz@users.sourceforge.net>
Mon, 29 May 2006 16:12:36 +0000 (16:12 +0000)
ChangeLog
src/desktop.cpp
src/dialogs/layers-panel.cpp
src/layer-manager.cpp

index f9a908f017c09140ef9bac6ac1b55f9b095f7140..4a6b28a802952ed2aea65926f7478b1450bdf0ec 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-05-29  Jon A. Cruz  <jon@joncruz.org>
+
+       * src/desktop.cpp, src/layer-manager.cpp, src/dialogs/layers-panel.cpp:
+       Workaround to avoid assertion upon file revert.
+
 2006-05-28  Bryce <bryce@bryceharrington.org>
        * sp-marker.cpp:  Adding documentation
 
@@ -37,7 +42,7 @@
 
 2006-05-28  Jon A. Cruz  <jon@joncruz.org>
 
-       * 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:
index b1dbae1187b5284b00e05cfc85cd8b8b62fb186f..17ce0907c67e3c6ffc8b9d8cb761737f74248885 100644 (file)
@@ -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);
 }
index cdcafbbc1c5d80d9b9a97dc1ac68627247027003..a09ce152724821604c93ba30dde9191a0a98aeae 100644 (file)
@@ -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 );
     }
 }
 
index e2e40340f6dff1d4d94e3594eba369429aa21585..61b0e15bb08cf3c00769f0b830aace539d0b7840 100644 (file)
@@ -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();
+        }
     }
 }