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/physics | |
parent | 15ef88b90239af30b08e798cc57cea317f1d56c9 (diff) |
poll functions to stop crashing when running operators in an invalid context.
Diffstat (limited to 'source/blender/editors/physics')
-rw-r--r-- | source/blender/editors/physics/ed_pointcache.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/source/blender/editors/physics/ed_pointcache.c b/source/blender/editors/physics/ed_pointcache.c index 68e0c28e9c1..22316290c7b 100644 --- a/source/blender/editors/physics/ed_pointcache.c +++ b/source/blender/editors/physics/ed_pointcache.c @@ -72,6 +72,12 @@ static int ptcache_bake_all_poll(bContext *C) return 1; } +static int ptcache_poll(bContext *C) +{ + PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache); + return (ptr.data && ptr.id.data); +} + static int ptcache_bake_all_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); @@ -215,7 +221,7 @@ void PTCACHE_OT_bake(wmOperatorType *ot) /* api callbacks */ ot->exec= ptcache_bake_exec; - ot->poll= ptcache_bake_all_poll; + ot->poll= ptcache_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -230,7 +236,7 @@ void PTCACHE_OT_free_bake(wmOperatorType *ot) /* api callbacks */ ot->exec= ptcache_free_bake_exec; - ot->poll= ptcache_bake_all_poll; + ot->poll= ptcache_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -243,7 +249,7 @@ void PTCACHE_OT_bake_from_cache(wmOperatorType *ot) /* api callbacks */ ot->exec= ptcache_bake_from_cache_exec; - ot->poll= ptcache_bake_all_poll; + ot->poll= ptcache_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -308,7 +314,7 @@ void PTCACHE_OT_add_new(wmOperatorType *ot) /* api callbacks */ ot->exec= ptcache_add_new_exec; - ot->poll= ptcache_bake_all_poll; + ot->poll= ptcache_poll; // ptcache_bake_all_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -321,7 +327,7 @@ void PTCACHE_OT_remove(wmOperatorType *ot) /* api callbacks */ ot->exec= ptcache_remove_exec; - ot->poll= ptcache_bake_all_poll; + ot->poll= ptcache_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; |