[f-spot] Fix disposed pixmap bug in Adjust Colours tool



commit 6a75488ee17f23de5a76c3c18297609711145581
Author: Christopher Halse Rogers <christopher halse rogers canonical com>
Date:   Mon May 17 18:31:03 2010 +0200

    Fix disposed pixmap bug in Adjust Colours tool
    
    The code paths in Adjustment.Adjust () for the alpha- and non- alpha
    channel cases have an important difference - the alpha channel codepath
    modifies Input and returns it, the non-alpha channel path returns a
    modified copy of Input.
    
    In the alpha case, returning Input eventually results in the preview
    pixmap being disposed, causing debug spew and (in View mode) the window
    to display garbage.

 src/ColorAdjustment/Adjustment.cs |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/src/ColorAdjustment/Adjustment.cs b/src/ColorAdjustment/Adjustment.cs
index 090aa16..094a660 100644
--- a/src/ColorAdjustment/Adjustment.cs
+++ b/src/ColorAdjustment/Adjustment.cs
@@ -64,16 +64,17 @@ namespace FSpot.ColorAdjustment {
 			Cms.Profile [] list = GenerateAdjustments ().ToArray ();
 			
 			if (Input.HasAlpha) {
+				Gdk.Pixbuf input_copy = (Gdk.Pixbuf)Input.Clone ();
 				Pixbuf alpha = PixbufUtils.Flatten (Input);
 				Transform transform = new Transform (list,
 								     PixbufUtils.PixbufCmsFormat (alpha),
 								     PixbufUtils.PixbufCmsFormat (final),
 								     intent, 0x0000);
 				PixbufUtils.ColorAdjust (alpha, final, transform);
-				PixbufUtils.ReplaceColor (final, Input);
+				PixbufUtils.ReplaceColor (final, input_copy);
 				alpha.Dispose ();
 				final.Dispose ();
-				final = Input;
+				final = input_copy;
 			} else {
 				Cms.Transform transform = new Cms.Transform (list,
 									     PixbufUtils.PixbufCmsFormat (Input),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]