Fix #29371: crash deleting objects in outliner. This was introduced in the
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 24 Nov 2011 20:24:03 +0000 (20:24 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 24 Nov 2011 20:24:03 +0000 (20:24 +0000)
bugfix for #28467, it deleted outliner tree while still traversing it.

source/blender/editors/space_outliner/outliner_tools.c

index 27ad2c4fd6d2885c3210d3dd1d81ef1fa4b40303..f4e46d0255d9658aee6def2ea6e2dbfa1cee1f3e 100644 (file)
@@ -297,8 +297,6 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto
        if(base==NULL) 
                base= object_in_scene((Object *)tselem->id, scene);
        if(base) {
-               SpaceOops *soops= CTX_wm_space_outliner(C);
-
                // check also library later
                if(scene->obedit==base->object) 
                        ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO);
@@ -306,15 +304,7 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto
                ED_base_object_free_and_unlink(CTX_data_main(C), scene, base);
                te->directdata= NULL;
                tselem->id= NULL;
-
-               /* XXX: tree management normally happens from draw_outliner(), but when
-                       you're clicking to fast on Delete object from context menu in
-                       outliner several mouse events can be handled in one cycle without
-                       handling notifiers/redraw which leads to deleting the same object twice.
-                       cleanup tree here to prevent such cases. */
-               outliner_cleanup_tree(soops);
        }
-
 }
 
 static void id_local_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
@@ -579,6 +569,14 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
        }
        else if(event==4) {
                outliner_do_object_operation(C, scene, soops, &soops->tree, object_delete_cb);
+
+               /* XXX: tree management normally happens from draw_outliner(), but when
+                       you're clicking to fast on Delete object from context menu in
+                       outliner several mouse events can be handled in one cycle without
+                       handling notifiers/redraw which leads to deleting the same object twice.
+                       cleanup tree here to prevent such cases. */
+               outliner_cleanup_tree(soops);
+
                DAG_scene_sort(bmain, scene);
                str= "Delete Objects";
                WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene);