[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43203] trunk/blender/source/blender: Fix #29568: Blender restores deleted scene

Sergey Sharybin sergey.vfx at gmail.com
Fri Jan 6 18:32:27 CET 2012


Revision: 43203
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43203
Author:   nazgul
Date:     2012-01-06 17:32:20 +0000 (Fri, 06 Jan 2012)
Log Message:
-----------
Fix #29568: Blender restores deleted scene

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.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/screen/screen_ops.c
    trunk/blender/source/blender/makesrna/intern/rna_screen.c
    trunk/blender/source/blender/windowmanager/intern/wm_event_system.c

Modified: trunk/blender/source/blender/editors/screen/screen_ops.c
===================================================================
--- trunk/blender/source/blender/editors/screen/screen_ops.c	2012-01-06 16:40:57 UTC (rev 43202)
+++ trunk/blender/source/blender/editors/screen/screen_ops.c	2012-01-06 17:32:20 UTC (rev 43203)
@@ -3309,7 +3309,6 @@
 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,12 +3327,10 @@
 		}
 	}
 	
-	/* this notifier calls ED_screen_set_scene, doing a lot of UI stuff, not for inside event loops */
+	ED_screen_set_scene(C, newscene);
+	
 	WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, newscene);
 	
-	if(screen)
-		screen->scene= newscene;
-	
 	return OPERATOR_FINISHED;
 }
 
@@ -3368,9 +3365,14 @@
 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;
 }
 

Modified: trunk/blender/source/blender/makesrna/intern/rna_screen.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_screen.c	2012-01-06 16:40:57 UTC (rev 43202)
+++ trunk/blender/source/blender/makesrna/intern/rna_screen.c	2012-01-06 17:32:20 UTC (rev 43203)
@@ -54,6 +54,7 @@
 
 #ifdef RNA_RUNTIME
 
+#include "BKE_global.h"
 
 static void rna_Screen_scene_set(PointerRNA *ptr, PointerRNA value)
 {
@@ -62,7 +63,6 @@
 	if(value.data == NULL)
 		return;
 
-	/* exception: can't set screens inside of area/region handers */
 	sc->newscene= value.data;
 }
 
@@ -70,10 +70,14 @@
 {
 	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;
 	}
 }

Modified: trunk/blender/source/blender/windowmanager/intern/wm_event_system.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_event_system.c	2012-01-06 16:40:57 UTC (rev 43202)
+++ trunk/blender/source/blender/windowmanager/intern/wm_event_system.c	2012-01-06 17:32:20 UTC (rev 43203)
@@ -225,20 +225,8 @@
 
 			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)) {



More information about the Bf-blender-cvs mailing list