Fix bug #22317 View reamins in camera's view after camera is deleted.
authorDiego Borghetti <bdiego@gmail.com>
Mon, 7 Jun 2010 16:24:24 +0000 (16:24 +0000)
committerDiego Borghetti <bdiego@gmail.com>
Mon, 7 Jun 2010 16:24:24 +0000 (16:24 +0000)
The object in the view3d don't get update, so point to the delete
camera and make Blender crash when you go into fly mode.

source/blender/editors/object/object_add.c

index 73fbc8e279543abdb19d01f0fe63d9d83dc6198c..e0e0bb06652f5581434489b6c029a526368fa7d3 100644 (file)
@@ -826,6 +826,8 @@ void ED_base_object_free_and_unlink(Scene *scene, Base *base)
 static int object_delete_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
+       View3D *v3d = CTX_wm_view3d(C);
+       RegionView3D *rv3d= CTX_wm_region_view3d(C);
        int islamp= 0;
        
        if(CTX_data_edit_object(C)) 
@@ -834,14 +836,24 @@ static int object_delete_exec(bContext *C, wmOperator *op)
        CTX_DATA_BEGIN(C, Base*, base, selected_bases) {
 
                if(base->object->type==OB_LAMP) islamp= 1;
-               
+               else if (base->object->type == OB_CAMERA) {
+                       /* If we don't reset this, Blender crash
+                        * in fly mode because still have the
+                        * old object here!.
+                        * See Bug #22317
+                        */
+                       if (v3d && rv3d && rv3d->persp == RV3D_CAMOB && base->object == v3d->camera) {
+                               rv3d->persp= RV3D_PERSP;
+                               v3d->camera= NULL;
+                       }
+               }
                /* remove from current scene only */
                ED_base_object_free_and_unlink(scene, base);
        }
        CTX_DATA_END;
 
        if(islamp) reshadeall_displist(scene);  /* only frees displist */
-       
+
        DAG_scene_sort(scene);
        DAG_ids_flush_update(0);