diff options
author | M.G. Kishalmi <lmg@kishalmi.net> | 2011-02-25 14:00:38 +0300 |
---|---|---|
committer | M.G. Kishalmi <lmg@kishalmi.net> | 2011-02-25 14:00:38 +0300 |
commit | e7101e21e1ac438384881ef1cfdcfb591597ae86 (patch) | |
tree | a189d2e48f526ebe1ce308ddb0b232d34d77756f /source/blender/editors | |
parent | 05c0eec5ffd44757f747290ad162c8b9959a29de (diff) |
bugfix #26211
render-result doesn't get an ibuf with BKE_image_get_ibuf
added a poll method to grey-out entries if !ibuf for now.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index f3688649ffc..25dd79ecc8e 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1347,7 +1347,18 @@ void IMAGE_OT_new(wmOperatorType *ot) /********************* invert operators *********************/ -static int image_invert_exec(bContext *C, wmOperator *op) { +static int image_invert_poll(bContext *C) +{ + Image *ima= CTX_data_edit_image(C); + ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); + + if( ibuf != NULL ) + return 1; + return 0; +} + +static int image_invert_exec(bContext *C, wmOperator *op) +{ Image *ima= CTX_data_edit_image(C); ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); @@ -1355,6 +1366,9 @@ static int image_invert_exec(bContext *C, wmOperator *op) { short r,g,b,a; int i, dirty = 0; + if( ibuf == NULL) // TODO: this should actually never happen, but does for render-results -> cleanup + return OPERATOR_CANCELLED; + r = RNA_boolean_get(op->ptr, "invert_r"); g = RNA_boolean_get(op->ptr, "invert_g"); b = RNA_boolean_get(op->ptr, "invert_b"); @@ -1394,13 +1408,15 @@ static int image_invert_exec(bContext *C, wmOperator *op) { } -void IMAGE_OT_invert(wmOperatorType *ot) { +void IMAGE_OT_invert(wmOperatorType *ot) +{ /* identifiers */ ot->name= "Invert Channels"; ot->idname= "IMAGE_OT_invert"; /* api callbacks */ ot->exec= image_invert_exec; + ot->poll= image_invert_poll; /* properties */ RNA_def_boolean(ot->srna, "invert_r", 0, "Red", "Invert Red Channel"); |