bugfix #26211
authorM.G. Kishalmi <lmg@kishalmi.net>
Fri, 25 Feb 2011 11:00:38 +0000 (11:00 +0000)
committerM.G. Kishalmi <lmg@kishalmi.net>
Fri, 25 Feb 2011 11:00:38 +0000 (11:00 +0000)
render-result doesn't get an ibuf with BKE_image_get_ibuf
added a poll method to grey-out entries if !ibuf for now.

source/blender/editors/space_image/image_ops.c

index f3688649ffc45b5b4810e1852b8ba86eb4b7d769..25dd79ecc8e15b3435ebca7528f4a9763256f7e9 100644 (file)
@@ -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");