Fix #28467: Crash while deleting objects in outliner too fast
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 2 Sep 2011 13:23:44 +0000 (13:23 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 2 Sep 2011 13:23:44 +0000 (13:23 +0000)
Cleanup tree when handling object delete from outliner.
Prevents handling the same tree item twice when clicking fast.

source/blender/editors/space_outliner/outliner_intern.h
source/blender/editors/space_outliner/outliner_tools.c
source/blender/editors/space_outliner/outliner_tree.c

index 2ddb57076237cf77b2dcfc6f3e1fab1b9458033b..61507d1ffe588d47a7a5aebaedf493b99e9f0cbb 100644 (file)
@@ -129,6 +129,7 @@ typedef struct TreeElement {
 /* outliner_tree.c ----------------------------------------------- */
 
 void outliner_free_tree(ListBase *lb);
+void outliner_cleanup_tree(struct SpaceOops *soops);
 
 TreeElement *outliner_find_tse(struct SpaceOops *soops, TreeStoreElem *tse);
 TreeElement *outliner_find_id(struct SpaceOops *soops, ListBase *lb, struct ID *id);
index 70dfbfe383008381fd25b9f94d599084868a6a2e..b3170f9cd1e34e1fc8fcf7d58666d4a632ad282e 100644 (file)
@@ -287,6 +287,8 @@ 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);
@@ -294,6 +296,13 @@ 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);
        }
 
 }
index 0b07c824f3e4e39e5f1dc16b8b0cc4da5149fff4..8904dcc360fc53e7b5da808879e2f8347e24bcc5 100644 (file)
@@ -222,6 +222,12 @@ void outliner_free_tree(ListBase *lb)
        }
 }
 
+void outliner_cleanup_tree(SpaceOops *soops)
+{
+       outliner_free_tree(&soops->tree);
+       outliner_storage_cleanup(soops);
+}
+
 /* Find ith item from the treestore */
 static TreeElement *outliner_find_tree_element(ListBase *lb, int store_index)
 {