bugfix [#24009] Crash when switching area types and performing ops

This commit is contained in:
2010-11-04 15:59:09 +00:00
parent 5fafa570d0
commit 6753882e42
15 changed files with 97 additions and 61 deletions

View File

@@ -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;

View File

@@ -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 **********************************/

View File

@@ -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 */

View File

@@ -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);

View File

@@ -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 */

View File

@@ -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);

View File

@@ -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);

View File

@@ -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)

View File

@@ -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++;
}
}
}

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);