bugfix [#24009] Crash when switching area types and performing ops
authorCampbell Barton <ideasman42@gmail.com>
Mon, 27 Sep 2010 10:44:46 +0000 (10:44 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 27 Sep 2010 10:44:46 +0000 (10:44 +0000)
tested every view3d operator to make sure none crash.

source/blender/editors/include/ED_screen.h
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/space_view3d/view3d_snap.c
source/blender/editors/space_view3d/view3d_view.c

index 8533de75a3cdfe02b896b5cacdc63e6327fa6878..203d93150eb0cc164733f6d7aee657e83b0a516e 100644 (file)
@@ -125,6 +125,7 @@ int         ED_operator_regionactive(struct bContext *C);
 int            ED_operator_scene_editable(struct bContext *C);
 
 int            ED_operator_view3d_active(struct bContext *C);
+int            ED_operator_region_view3d_active(struct bContext *C);
 int            ED_operator_timeline_active(struct bContext *C);
 int            ED_operator_outliner_active(struct bContext *C);
 int            ED_operator_file_active(struct bContext *C);
index e5f20e3c75a9a6ac1f919315fc7f21aff6f81460..9c14be1bd9a3ac85a3850a0afbab6dd99bc5f748 100644 (file)
@@ -129,6 +129,11 @@ int ED_operator_view3d_active(bContext *C)
        return ed_spacetype_test(C, SPACE_VIEW3D);
 }
 
+int ED_operator_region_view3d_active(bContext *C)
+{
+       return CTX_wm_region_view3d(C) != NULL;
+}
+
 int ED_operator_timeline_active(bContext *C)
 {
        return ed_spacetype_test(C, SPACE_TIME);
index e2c12386dd357cd2d476175a40d3d474222725cc..13e5d7bbc96347f195e57a4f3ef3ebca6fe267c2 100644 (file)
@@ -783,7 +783,7 @@ static int view3d_camera_active_poll(bContext *C)
 
 static int view3d_rotate_poll(bContext *C)
 {
-       if (!ED_operator_view3d_active(C)) {
+       if (!ED_operator_region_view3d_active(C)) {
                return 0;
        } else {
                RegionView3D *rv3d= CTX_wm_region_view3d(C);
@@ -1264,7 +1264,7 @@ void VIEW3D_OT_zoom(wmOperatorType *ot)
        ot->invoke= viewzoom_invoke;
        ot->exec= viewzoom_exec;
        ot->modal= viewzoom_modal;
-       ot->poll= ED_operator_view3d_active;
+       ot->poll= ED_operator_region_view3d_active;
 
        /* flags */
        ot->flag= OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER;
@@ -1522,7 +1522,7 @@ void VIEW3D_OT_view_selected(wmOperatorType *ot)
 
        /* api callbacks */
        ot->exec= viewselected_exec;
-       ot->poll= ED_operator_view3d_active;
+       ot->poll= ED_operator_region_view3d_active;
 
        /* flags */
        ot->flag= 0;
@@ -1822,7 +1822,7 @@ void VIEW3D_OT_zoom_border(wmOperatorType *ot)
        ot->exec= view3d_zoom_border_exec;
        ot->modal= WM_border_select_modal;
 
-       ot->poll= ED_operator_view3d_active;
+       ot->poll= ED_operator_region_view3d_active;
 
        /* flags */
        ot->flag= 0;
@@ -2044,7 +2044,7 @@ void VIEW3D_OT_viewnumpad(wmOperatorType *ot)
 
        /* api callbacks */
        ot->exec= viewnumpad_exec;
-       ot->poll= ED_operator_view3d_active;
+       ot->poll= ED_operator_region_view3d_active;
 
        /* flags */
        ot->flag= 0;
@@ -2162,7 +2162,7 @@ void VIEW3D_OT_view_pan(wmOperatorType *ot)
 
        /* api callbacks */
        ot->exec= viewpan_exec;
-       ot->poll= ED_operator_view3d_active;
+       ot->poll= ED_operator_region_view3d_active;
 
        /* flags */
        ot->flag= 0;
@@ -2194,7 +2194,7 @@ void VIEW3D_OT_view_persportho(wmOperatorType *ot)
 
        /* api callbacks */
        ot->exec= viewpersportho_exec;
-       ot->poll= ED_operator_view3d_active;
+       ot->poll= ED_operator_region_view3d_active;
 
        /* flags */
        ot->flag= 0;
@@ -2413,7 +2413,7 @@ void VIEW3D_OT_clip_border(wmOperatorType *ot)
        ot->exec= view3d_clipping_exec;
        ot->modal= WM_border_select_modal;
 
-       ot->poll= ED_operator_view3d_active;
+       ot->poll= ED_operator_region_view3d_active;
 
        /* flags */
        ot->flag= 0;
index cc4defacb353cd1251ca7266c8c6faf3f6cb657d..7e6e8e0e6af40c853adb2d9bfc8082c3c4827913 100644 (file)
@@ -215,7 +215,7 @@ static int view3d_selectable_data(bContext *C)
 {
        Object *ob = CTX_data_active_object(C);
        
-       if (!ED_operator_view3d_active(C))
+       if (!ED_operator_region_view3d_active(C))
                return 0;
        
        if (!CTX_data_edit_object(C))
index 5ee87db6b682346e4bbd0f014487cc03e8771ff3..7f5f766502881fabebfe65f457cf895d2faf5b89 100644 (file)
@@ -569,7 +569,7 @@ void VIEW3D_OT_snap_selected_to_grid(wmOperatorType *ot)
        
        /* api callbacks */
        ot->exec= snap_sel_to_grid;
-       ot->poll= ED_operator_view3d_active;
+       ot->poll= ED_operator_region_view3d_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -732,7 +732,7 @@ void VIEW3D_OT_snap_cursor_to_grid(wmOperatorType *ot)
        
        /* api callbacks */
        ot->exec= snap_curs_to_grid;
-       ot->poll= ED_operator_view3d_active;
+       ot->poll= ED_operator_region_view3d_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
index 6a3c121ce4bdc5a9ec67e1e2d6cc17ea21716dc8..146e90baeb1cb6be09bb8db9a0e3cc31fb1aa213 100644 (file)
@@ -472,7 +472,7 @@ void VIEW3D_OT_object_as_camera(wmOperatorType *ot)
        
        /* api callbacks */
        ot->exec= view3d_setobjectascamera_exec;        
-       ot->poll= ED_operator_view3d_active;
+       ot->poll= ED_operator_region_view3d_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;