Fix #29568: Blender restores deleted scene
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 6 Jan 2012 17:32:20 +0000 (17:32 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 6 Jan 2012 17:32:20 +0000 (17:32 +0000)
Special notifiers used for scene deletion which lead to undo pushes
after SCENE_OT_delete operator happening with scene still present in
the mainfile. That was a reason why operator redo used to restore
scene.

It's not so obvious why special notifier type is needed for scene
set and deletion -- it confuses undo system without having some
obvious advantages. Using "direct" scene deletion and setting
seems to be working fine so let's see if there'll be some issues
with this.

source/blender/editors/screen/screen_ops.c
source/blender/makesrna/intern/rna_screen.c
source/blender/windowmanager/intern/wm_event_system.c

index ffdfea7fde5b0fd037235676ab803fac24e3bad8..98f850091406e8adaadb5538c1fbae3cee393c34 100644 (file)
@@ -3309,7 +3309,6 @@ static void SCREEN_OT_delete(wmOperatorType *ot)
 static int scene_new_exec(bContext *C, wmOperator *op)
 {
        Scene *newscene, *scene= CTX_data_scene(C);
-       bScreen *screen= CTX_wm_screen(C);
        Main *bmain= CTX_data_main(C);
        int type= RNA_enum_get(op->ptr, "type");
 
@@ -3328,11 +3327,9 @@ static int scene_new_exec(bContext *C, wmOperator *op)
                }
        }
        
-       /* this notifier calls ED_screen_set_scene, doing a lot of UI stuff, not for inside event loops */
-       WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, newscene);
+       ED_screen_set_scene(C, newscene);
        
-       if(screen)
-               screen->scene= newscene;
+       WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, newscene);
        
        return OPERATOR_FINISHED;
 }
@@ -3368,9 +3365,14 @@ static void SCENE_OT_new(wmOperatorType *ot)
 static int scene_delete_exec(bContext *C, wmOperator *UNUSED(op))
 {
        Scene *scene= CTX_data_scene(C);
-       
+
+       ED_screen_delete_scene(C, scene);
+
+       if(G.f & G_DEBUG)
+               printf("scene delete %p\n", scene);
+
        WM_event_add_notifier(C, NC_SCENE|NA_REMOVED, scene);
-       
+
        return OPERATOR_FINISHED;
 }
 
index c8792ef30f393865323f8a1c8f8e0c0e2a7f9c0a..fa1f6c72430beca073936a9c42a92e7c4f2496ee 100644 (file)
@@ -54,6 +54,7 @@ EnumPropertyItem region_type_items[] = {
 
 #ifdef RNA_RUNTIME
 
+#include "BKE_global.h"
 
 static void rna_Screen_scene_set(PointerRNA *ptr, PointerRNA value)
 {
@@ -62,7 +63,6 @@ static void rna_Screen_scene_set(PointerRNA *ptr, PointerRNA value)
        if(value.data == NULL)
                return;
 
-       /* exception: can't set screens inside of area/region handers */
        sc->newscene= value.data;
 }
 
@@ -70,10 +70,14 @@ static void rna_Screen_scene_update(bContext *C, PointerRNA *ptr)
 {
        bScreen *sc= (bScreen*)ptr->data;
 
-       /* exception: can't set screens inside of area/region handers, and must
-          use context so notifier gets to the right window  */
+       /* exception: must use context so notifier gets to the right window  */
        if(sc->newscene) {
+               ED_screen_set_scene(C, sc->newscene);
                WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, sc->newscene);
+
+               if(G.f & G_DEBUG)
+                       printf("scene set %p\n", sc->newscene);
+
                sc->newscene= NULL;
        }
 }
index 43a691770c998d8f1e2c4e2573344bd5b02c47a0..43ed2b3b2b988810ba0c8a5a927fad1e14551a98 100644 (file)
@@ -225,20 +225,8 @@ void wm_event_do_notifiers(bContext *C)
 
                        if(note->window==win || (note->window == NULL && (note->reference == NULL || note->reference == CTX_data_scene(C)))) {
                                if(note->category==NC_SCENE) {
-                                       if(note->data==ND_SCENEBROWSE) {
-                                               ED_screen_set_scene(C, note->reference);        // XXX hrms, think this over!
-                                               if(G.f & G_DEBUG)
-                                                       printf("scene set %p\n", note->reference);
-                                       }
-                                       else if(note->data==ND_FRAME)
+                                       if(note->data==ND_FRAME)
                                                do_anim= 1;
-                                       
-                                       if(note->action == NA_REMOVED) {
-                                               ED_screen_delete_scene(C, note->reference);     // XXX hrms, think this over!
-                                               if(G.f & G_DEBUG)
-                                                       printf("scene delete %p\n", note->reference);
-                                       }
-                                               
                                }
                        }
                        if(ELEM5(note->category, NC_SCENE, NC_OBJECT, NC_GEOM, NC_SCENE, NC_WM)) {