diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-09-04 12:49:11 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-09-04 12:49:11 +0400 |
commit | 6ed49857a4408bf413f4bf626229aa00d6c8cad7 (patch) | |
tree | fe28f1a9577172536f7ef33bfbaf0e84bf55ef1c /source/blender/editors/space_buttons | |
parent | 15ef88b90239af30b08e798cc57cea317f1d56c9 (diff) |
poll functions to stop crashing when running operators in an invalid context.
Diffstat (limited to 'source/blender/editors/space_buttons')
-rw-r--r-- | source/blender/editors/space_buttons/buttons_ops.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index 057f35a2487..954a52c54aa 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -613,6 +613,12 @@ void OBJECT_OT_particle_system_remove(wmOperatorType *ot) /********************** new particle settings operator *********************/ +static int psys_poll(bContext *C) +{ + PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); + return (ptr.data != NULL); +} + static int new_particle_settings_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); @@ -657,6 +663,7 @@ void PARTICLE_OT_new(wmOperatorType *ot) /* api callbacks */ ot->exec= new_particle_settings_exec; + ot->poll= psys_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -948,6 +955,9 @@ static int file_browse_exec(bContext *C, wmOperator *op) FileBrowseOp *fbo= op->customdata; char *str; + if (RNA_property_is_set(op->ptr, "filename")==0 || fbo==NULL) + return OPERATOR_CANCELLED; + str= RNA_string_get_alloc(op->ptr, "filename", 0, 0); RNA_property_string_set(&fbo->ptr, fbo->prop, str); RNA_property_update(C, &fbo->ptr, fbo->prop); |