diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-11-04 18:59:09 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-11-04 18:59:09 +0300 |
commit | 6753882e42282ccf9dea49bdef2fc5455d852710 (patch) | |
tree | 5cc4fea764a9eb72b05d5c233d3549c52d7c7e02 | |
parent | 5fafa570d06a920fcbd73b0e5b1944846cce43ed (diff) |
bugfix [#24009] Crash when switching area types and performing ops
-rw-r--r-- | source/blender/editors/animation/anim_markers.c | 18 | ||||
-rw-r--r-- | source/blender/editors/animation/anim_ops.c | 6 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_paint.c | 16 | ||||
-rw-r--r-- | source/blender/editors/include/ED_screen.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d_ops.c | 4 | ||||
-rw-r--r-- | source/blender/editors/object/object_add.c | 5 | ||||
-rw-r--r-- | source/blender/editors/object/object_constraint.c | 5 | ||||
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 11 | ||||
-rw-r--r-- | source/blender/editors/render/render_shading.c | 54 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 27 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 1 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_ops.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 3 |
15 files changed, 97 insertions, 61 deletions
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 055ee1c3392..2f5ad28c8f2 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -376,7 +376,7 @@ static void MARKER_OT_add(wmOperatorType *ot) /* api callbacks */ ot->exec= ed_marker_add; - ot->poll= ED_operator_areaactive; + ot->poll= ED_operator_animview_active; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -667,7 +667,7 @@ static void MARKER_OT_move(wmOperatorType *ot) ot->exec= ed_marker_move_exec; ot->invoke= ed_marker_move_invoke; ot->modal= ed_marker_move_modal; - ot->poll= ED_operator_areaactive; + ot->poll= ED_operator_animview_active; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER; @@ -755,7 +755,7 @@ static void MARKER_OT_duplicate(wmOperatorType *ot) ot->exec= ed_marker_duplicate_exec; ot->invoke= ed_marker_duplicate_invoke; ot->modal= ed_marker_move_modal; - ot->poll= ED_operator_areaactive; + ot->poll= ED_operator_animview_active; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -870,7 +870,7 @@ static void MARKER_OT_select(wmOperatorType *ot) /* api callbacks */ ot->invoke= ed_marker_select_invoke; - ot->poll= ED_operator_areaactive; + ot->poll= ED_operator_animview_active; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -958,7 +958,7 @@ static void MARKER_OT_select_border(wmOperatorType *ot) ot->invoke= WM_border_select_invoke; ot->modal= WM_border_select_modal; - ot->poll= ED_operator_areaactive; + ot->poll= ED_operator_animview_active; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1021,7 +1021,7 @@ static void MARKER_OT_select_all(wmOperatorType *ot) /* api callbacks */ ot->exec= ed_marker_select_all_exec; - ot->poll= ED_operator_areaactive; + ot->poll= ED_operator_animview_active; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1069,7 +1069,7 @@ static void MARKER_OT_delete(wmOperatorType *ot) /* api callbacks */ ot->invoke= WM_operator_confirm; ot->exec= ed_marker_delete_exec; - ot->poll= ED_operator_areaactive; + ot->poll= ED_operator_animview_active; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1114,7 +1114,7 @@ static void MARKER_OT_make_links_scene(wmOperatorType *ot) /* api callbacks */ ot->exec= ed_marker_make_links_scene_exec; - ot->poll= ED_operator_areaactive; + ot->poll= ED_operator_animview_active; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1163,7 +1163,7 @@ static void MARKER_OT_camera_bind(wmOperatorType *ot) /* api callbacks */ ot->exec= ed_marker_camera_bind_exec; - ot->poll= ED_operator_areaactive; + ot->poll= ED_operator_animview_active; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index a80ea3e12bf..9b367481ef2 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -217,7 +217,7 @@ void ANIM_OT_previewrange_set(wmOperatorType *ot) ot->exec= previewrange_define_exec; ot->modal= WM_border_select_modal; - ot->poll= ED_operator_areaactive; + ot->poll= ED_operator_animview_active; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -261,7 +261,7 @@ void ANIM_OT_previewrange_clear(wmOperatorType *ot) /* api callbacks */ ot->exec= previewrange_clear_exec; - ot->poll= ED_operator_areaactive; + ot->poll= ED_operator_animview_active; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -328,7 +328,7 @@ void ANIM_OT_time_toggle(wmOperatorType *ot) /* api callbacks */ ot->exec= toggle_time_exec; - ot->poll= ED_operator_areaactive; + ot->poll= ED_operator_animview_active; } /* ************************** registration **********************************/ diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 23e2755613c..d42e63bf354 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -141,8 +141,20 @@ static void gp_session_validatebuffer(tGPsdata *p); /* check if context is suitable for drawing */ static int gpencil_draw_poll (bContext *C) { - /* check if current context can support GPencil data */ - return (gpencil_data_get_pointers(C, NULL) != NULL); + if(ED_operator_regionactive(C)) { + /* check if current context can support GPencil data */ + if(gpencil_data_get_pointers(C, NULL) != NULL) { + return 1; + } + else { + CTX_wm_operator_poll_msg_set(C, "failed to find grease pencil data to draw into"); + } + } + else { + CTX_wm_operator_poll_msg_set(C, "active region not set"); + } + + return 0; } /* check if projecting strokes into 3d-geometry in the 3D-View */ diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 6904daa9868..b679ca64a28 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -128,6 +128,7 @@ 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_animview_active(struct bContext *C); int ED_operator_timeline_active(struct bContext *C); int ED_operator_outliner_active(struct bContext *C); int ED_operator_outliner_active_no_editobject(struct bContext *C); @@ -143,6 +144,7 @@ int ED_operator_logic_active(struct bContext *C); int ED_operator_object_active(struct bContext *C); int ED_operator_object_active_editable(struct bContext *C); +int ED_operator_object_active_editable_mesh(struct bContext *C); int ED_operator_editmesh(struct bContext *C); int ED_operator_editmesh_view3d(struct bContext *C); int ED_operator_editmesh_region_view3d(struct bContext *C); diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 48523ec1a5a..a755cfaa9e3 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -689,7 +689,7 @@ void VIEW2D_OT_zoom_in(wmOperatorType *ot) /* api callbacks */ ot->invoke= view_zoomin_invoke; - ot->exec= view_zoomin_exec; +// ot->exec= view_zoomin_exec; // XXX, needs view_zoomdrag_init called first. ot->poll= view_zoom_poll; /* rna - must keep these in sync with the other operators */ @@ -746,7 +746,7 @@ void VIEW2D_OT_zoom_out(wmOperatorType *ot) /* api callbacks */ ot->invoke= view_zoomout_invoke; - ot->exec= view_zoomout_exec; +// ot->exec= view_zoomout_exec; // XXX, needs view_zoomdrag_init called first. ot->poll= view_zoom_poll; /* rna - must keep these in sync with the other operators */ diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 9c234266673..196440f29cf 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -607,7 +607,7 @@ static int object_armature_add_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); View3D *v3d= CTX_wm_view3d(C); - RegionView3D *rv3d= NULL; + RegionView3D *rv3d= CTX_wm_region_view3d(C); int newob= 0; int enter_editmode; unsigned int layer; @@ -629,9 +629,6 @@ static int object_armature_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - if(v3d) - rv3d= CTX_wm_region(C)->regiondata; - /* v3d and rv3d are allowed to be NULL */ add_primitive_bone(CTX_data_scene(C), v3d, rv3d); diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index d3b26100727..e222913e703 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -726,6 +726,11 @@ static int childof_clear_inverse_exec (bContext *C, wmOperator *op) bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF); bChildOfConstraint *data= (con) ? (bChildOfConstraint *)con->data : NULL; + if(data==NULL) { + BKE_report(op->reports, RPT_ERROR, "Childof constraint not found."); + return OPERATOR_CANCELLED; + } + /* simply clear the matrix */ unit_m4(data->invmat); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 3d36ed9f45e..a9759c8c838 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -603,12 +603,13 @@ void OBJECT_OT_modifier_add(wmOperatorType *ot) /************************ generic functions for operators using mod names and data context *********************/ -static int edit_modifier_poll_generic(bContext *C, StructRNA *rna_type) +static int edit_modifier_poll_generic(bContext *C, StructRNA *rna_type, int obtype_flag) { PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", rna_type); Object *ob= (ptr.id.data)?ptr.id.data:ED_object_active_context(C); if (!ob || ob->id.lib) return 0; + if (obtype_flag && ((1<<ob->type) & obtype_flag)==0) return 0; if (ptr.data && ((ID*)ptr.id.data)->lib) return 0; return 1; @@ -616,7 +617,7 @@ static int edit_modifier_poll_generic(bContext *C, StructRNA *rna_type) static int edit_modifier_poll(bContext *C) { - return edit_modifier_poll_generic(C, &RNA_Modifier); + return edit_modifier_poll_generic(C, &RNA_Modifier, 0); } static void edit_modifier_properties(wmOperatorType *ot) @@ -913,7 +914,7 @@ void OBJECT_OT_modifier_copy(wmOperatorType *ot) static int multires_poll(bContext *C) { - return edit_modifier_poll_generic(C, &RNA_MultiresModifier); + return edit_modifier_poll_generic(C, &RNA_MultiresModifier, (1<<OB_MESH)); } static int multires_higher_levels_delete_exec(bContext *C, wmOperator *op) @@ -1163,7 +1164,7 @@ void OBJECT_OT_multires_external_pack(wmOperatorType *ot) static int meshdeform_poll(bContext *C) { - return edit_modifier_poll_generic(C, &RNA_MeshDeformModifier); + return edit_modifier_poll_generic(C, &RNA_MeshDeformModifier, (1<<OB_MESH)); } static int meshdeform_bind_exec(bContext *C, wmOperator *op) @@ -1251,7 +1252,7 @@ void OBJECT_OT_meshdeform_bind(wmOperatorType *ot) static int explode_poll(bContext *C) { - return edit_modifier_poll_generic(C, &RNA_ExplodeModifier); + return edit_modifier_poll_generic(C, &RNA_ExplodeModifier, 0); } static int explode_refresh_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 9db15ee43e5..16bdaae2bf5 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -399,36 +399,38 @@ static int material_slot_de_select(bContext *C, int select) BezTriple *bezt; int a; - for(nu= nurbs->first; nu; nu=nu->next) { - if(nu->mat_nr==ob->actcol-1) { - if(nu->bezt) { - a= nu->pntsu; - bezt= nu->bezt; - while(a--) { - if(bezt->hide==0) { - if(select) { - bezt->f1 |= SELECT; - bezt->f2 |= SELECT; - bezt->f3 |= SELECT; - } - else { - bezt->f1 &= ~SELECT; - bezt->f2 &= ~SELECT; - bezt->f3 &= ~SELECT; + if(nurbs) { + for(nu= nurbs->first; nu; nu=nu->next) { + if(nu->mat_nr==ob->actcol-1) { + if(nu->bezt) { + a= nu->pntsu; + bezt= nu->bezt; + while(a--) { + if(bezt->hide==0) { + if(select) { + bezt->f1 |= SELECT; + bezt->f2 |= SELECT; + bezt->f3 |= SELECT; + } + else { + bezt->f1 &= ~SELECT; + bezt->f2 &= ~SELECT; + bezt->f3 &= ~SELECT; + } } + bezt++; } - bezt++; } - } - else if(nu->bp) { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; - while(a--) { - if(bp->hide==0) { - if(select) bp->f1 |= SELECT; - else bp->f1 &= ~SELECT; + else if(nu->bp) { + a= nu->pntsu*nu->pntsv; + bp= nu->bp; + while(a--) { + if(bp->hide==0) { + if(select) bp->f1 |= SELECT; + else bp->f1 &= ~SELECT; + } + bp++; } - bp++; } } } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 845ef2bae4d..7cdd19e435b 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -132,17 +132,26 @@ int ED_operator_view3d_active(bContext *C) int ED_operator_region_view3d_active(bContext *C) { -#if 0 // correct but messes up poll() for menu items. if(CTX_wm_region_view3d(C)) return TRUE; -#else - if(ed_spacetype_test(C, SPACE_VIEW3D)) - return TRUE; -#endif + CTX_wm_operator_poll_msg_set(C, "expected a view3d region"); return FALSE; } +/* generic for any view2d which uses anim_ops */ +int ED_operator_animview_active(bContext *C) +{ + if(ED_operator_areaactive(C)) { + SpaceLink *sl= (SpaceLink *)CTX_wm_space_data(C); + if (sl && (ELEM5(sl->spacetype, SPACE_SEQ, SPACE_SOUND, SPACE_ACTION, SPACE_NLA, SPACE_TIME))) + return TRUE; + } + + CTX_wm_operator_poll_msg_set(C, "expected an timeline/animation area to be active"); + return 0; +} + int ED_operator_timeline_active(bContext *C) { return ed_spacetype_test(C, SPACE_TIME); @@ -229,6 +238,12 @@ int ED_operator_object_active_editable(bContext *C) return ((ob != NULL) && !(ob->id.lib) && !(ob->restrictflag & OB_RESTRICT_VIEW)); } +int ED_operator_object_active_editable_mesh(bContext *C) +{ + Object *ob = ED_object_active_context(C); + return ((ob != NULL) && !(ob->id.lib) && !(ob->restrictflag & OB_RESTRICT_VIEW) && ob->type == OB_MESH); +} + int ED_operator_editmesh(bContext *C) { Object *obedit= CTX_data_edit_object(C); @@ -2248,7 +2263,7 @@ static void SCREEN_OT_region_quadview(wmOperatorType *ot) /* api callbacks */ // ot->invoke= WM_operator_confirm; ot->exec= region_quadview_exec; - ot->poll= ED_operator_areaactive; + ot->poll= ED_operator_region_view3d_active; ot->flag= 0; } diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index b6e7c823c9d..c5402a00942 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -5587,6 +5587,7 @@ void PAINT_OT_image_from_view(wmOperatorType *ot) /* api callbacks */ ot->exec= texture_paint_image_from_view_exec; + ot->poll= ED_operator_region_view3d_active; /* flags */ ot->flag= OPTYPE_REGISTER; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index fccee048525..efc39e6ae0a 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3658,7 +3658,7 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot) /* api callbacks */ ot->exec= sculpt_toggle_mode; - ot->poll= ED_operator_object_active; + ot->poll= ED_operator_object_active_editable_mesh; ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 1a0514c9735..32b71dbefb7 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -171,9 +171,9 @@ static int new_exec(bContext *C, wmOperator *UNUSED(op)) else if(st) { st->text= text; st->top= 0; + text_drawcache_tag_update(st, 1); } - text_drawcache_tag_update(st, 1); WM_event_add_notifier(C, NC_TEXT|NA_ADDED, text); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 18091942973..9fbfd12f902 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1366,7 +1366,7 @@ void VIEW3D_OT_view_all(wmOperatorType *ot) /* api callbacks */ ot->exec= view3d_all_exec; - ot->poll= ED_operator_view3d_active; + ot->poll= ED_operator_region_view3d_active; /* flags */ ot->flag= 0; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index fa300d51724..7fa58db54bb 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -3005,7 +3005,8 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) for(a=0; a<iter; a++) { if (type==0) { - ED_region_do_draw(C, ar); + if(ar) + ED_region_do_draw(C, ar); } else if (type==1) { wmWindow *win= CTX_wm_window(C); |