git: 9front

Download patch

ref: 798cbac73bdf28dde2991fcc29b74afba74b23f3
parent: 8678b005454a1743c78ab06ea1bb8f8372f84548
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Tue Jun 25 22:27:35 EDT 2013

paint: restore color channel on undo after conversion thru pipe

converting image thru pipe would not properly restore the
original color channel on undo. like |iconv -c k8 would
still be grayscale after undo.

--- a/sys/src/cmd/paint.c
+++ b/sys/src/cmd/paint.c
@@ -259,10 +259,16 @@
 		if((tmp = undo[x]) == nil)
 			return;
 		undo[x] = nil;
-		expand(tmp->r);
-		draw(canvas, tmp->r, tmp, nil, tmp->r.min);
-		update(&tmp->r);
-		freeimage(tmp);
+		if(canvas != nil && canvas->chan != tmp->chan){
+			freeimage(canvas);
+			canvas = tmp;
+			update(nil);
+		} else {
+			expand(tmp->r);
+			draw(canvas, tmp->r, tmp, nil, tmp->r.min);
+			update(&tmp->r);
+			freeimage(tmp);
+		}
 	}
 }
 
--