[f-spot] Always return a disposable pixbuf in TransformOrientation.
- From: Ruben Vermeersch <rubenv src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [f-spot] Always return a disposable pixbuf in TransformOrientation.
- Date: Tue, 4 Aug 2009 11:11:27 +0000 (UTC)
commit cc3826191f4315357e4b9323fbda9aba2ef790cb
Author: Ruben Vermeersch <ruben savanne be>
Date: Tue Aug 4 13:09:14 2009 +0200
Always return a disposable pixbuf in TransformOrientation.
Fix some PixbufUtils behavior fail.
This commit might or might not fix Bug 588998 â?? Unable to change tag
icon using icon from photo.
src/FSpot.Utils.dll.config | 1 +
src/Imaging/ImageFile.cs | 5 +--
src/Imaging/JpegFile.cs | 4 +--
src/Loupe.cs | 5 +--
src/PixbufUtils.cs | 38 ++++++----------------------------
src/ThumbnailGenerator.cs | 4 +-
src/UI.Dialog/EditTagIconDialog.cs | 3 +-
src/Utils/PixbufUtils.cs | 39 ++++++++++++++++++++++++++++++++++-
src/Widgets/IconView.cs | 2 +-
9 files changed, 54 insertions(+), 47 deletions(-)
---
diff --git a/src/FSpot.Utils.dll.config b/src/FSpot.Utils.dll.config
index 09effb6..20b20ab 100644
--- a/src/FSpot.Utils.dll.config
+++ b/src/FSpot.Utils.dll.config
@@ -1,4 +1,5 @@
<configuration>
<dllmap dll="libgdk-2.0-0.dll" target="libgdk-x11-2.0.so.0"/>
+ <dllmap dll="libgdk_pixbuf-2.0-0.dll" target="libgdk_pixbuf-2.0.so.0"/>
<dllmap dll="X11" target="libX11.so.6"/>
</configuration>
diff --git a/src/Imaging/ImageFile.cs b/src/Imaging/ImageFile.cs
index 7309c81..e1bb72e 100644
--- a/src/Imaging/ImageFile.cs
+++ b/src/Imaging/ImageFile.cs
@@ -99,9 +99,8 @@ namespace FSpot {
return null;
Gdk.Pixbuf rotated = FSpot.Utils.PixbufUtils.TransformOrientation (orig, this.Orientation);
- //ValidateThumbnail (photo, rotated);
- if (rotated != orig)
- orig.Dispose ();
+
+ orig.Dispose ();
return rotated;
}
diff --git a/src/Imaging/JpegFile.cs b/src/Imaging/JpegFile.cs
index 02fccbe..ff17905 100644
--- a/src/Imaging/JpegFile.cs
+++ b/src/Imaging/JpegFile.cs
@@ -248,9 +248,7 @@ namespace FSpot {
MemoryStream mem = new MemoryStream (this.ExifData.Data);
Gdk.Pixbuf thumb = new Gdk.Pixbuf (mem);
Gdk.Pixbuf rotated = FSpot.Utils.PixbufUtils.TransformOrientation (thumb, this.Orientation);
-
- if (rotated != thumb)
- thumb.Dispose ();
+ thumb.Dispose ();
mem.Close ();
return rotated;
diff --git a/src/Loupe.cs b/src/Loupe.cs
index 34ae14b..af36848 100644
--- a/src/Loupe.cs
+++ b/src/Loupe.cs
@@ -163,9 +163,8 @@ namespace FSpot.Widgets {
Pixbuf tmp = new Gdk.Pixbuf (view.Pixbuf,
region.X, region.Y,
region.Width, region.Height);
- source = FSpot.Utils.PixbufUtils.TransformOrientation (tmp, view.PixbufOrientation);
- if (source != tmp)
- tmp.Dispose ();
+ using (tmp)
+ source = FSpot.Utils.PixbufUtils.TransformOrientation (tmp, view.PixbufOrientation);
//FIXME sometimes that ctor returns results with a null
//handle this case ourselves
diff --git a/src/PixbufUtils.cs b/src/PixbufUtils.cs
index d2e34cf..87baa26 100644
--- a/src/PixbufUtils.cs
+++ b/src/PixbufUtils.cs
@@ -6,7 +6,7 @@
// Larry Ewing <lewing novell com>
// Stephane Delcroix <stephane declroix org>
//
-// This is free softwae. See cOPYING for details
+// This is free software. See COPYING for details
//
using Gdk;
@@ -121,7 +121,7 @@ public class PixbufUtils {
Gdk.Pixbuf rotated = FSpot.Utils.PixbufUtils.TransformOrientation (orig, orientation);
if (orig != rotated) {
- CopyThumbnailOptions (orig, rotated);
+ FSpot.Utils.PixbufUtils.CopyThumbnailOptions (orig, rotated);
orig.Dispose ();
}
loader.Dispose ();
@@ -147,7 +147,7 @@ public class PixbufUtils {
if (pixbuf == null)
return null;
Pixbuf result = new Pixbuf (pixbuf, 0, 0, pixbuf.Width, pixbuf.Height);
- CopyThumbnailOptions (pixbuf, result);
+ FSpot.Utils.PixbufUtils.CopyThumbnailOptions (pixbuf, result);
return result;
}
@@ -168,7 +168,7 @@ public class PixbufUtils {
else
result = pixbuf.Copy ();
- CopyThumbnailOptions (pixbuf, result);
+ FSpot.Utils.PixbufUtils.CopyThumbnailOptions (pixbuf, result);
return result;
}
@@ -238,30 +238,6 @@ public class PixbufUtils {
}
- //
- // FIXME this is actually not public api and we should do a verison check,
- // but frankly I'm irritated that it isn't public so I don't much care.
- //
- [DllImport("libgdk_pixbuf-2.0-0.dll")]
- static extern bool gdk_pixbuf_set_option(IntPtr raw, string key, string value);
-
- public static bool SetOption(Gdk.Pixbuf pixbuf, string key, string value)
- {
-
- if (value != null)
- return gdk_pixbuf_set_option(pixbuf.Handle, key, value);
- else
- return false;
- }
-
- public static void CopyThumbnailOptions (Gdk.Pixbuf src, Gdk.Pixbuf dest)
- {
- if (src != null && dest != null) {
- PixbufUtils.SetOption (dest, "tEXt::Thumb::URI", src.GetOption ("tEXt::Thumb::URI"));
- PixbufUtils.SetOption (dest, "tEXt::Thumb::MTime", src.GetOption ("tEXt::Thumb::MTime"));
- }
- }
-
public static void Save (Gdk.Pixbuf pixbuf, System.IO.Stream stream, string type, string [] options, string [] values)
{
byte [] data;
@@ -674,11 +650,11 @@ public class PixbufUtils {
using (MemoryStream mem = new MemoryStream (thumb_data)) {
Gdk.Pixbuf thumb = new Gdk.Pixbuf (mem);
+ Gdk.Pixbuf rotated;
- Gdk.Pixbuf rotated = FSpot.Utils.PixbufUtils.TransformOrientation (thumb, orientation);
+ using (thumb)
+ rotated = FSpot.Utils.PixbufUtils.TransformOrientation (thumb, orientation);
- if (rotated != thumb)
- thumb.Dispose ();
return rotated;
}
}
diff --git a/src/ThumbnailGenerator.cs b/src/ThumbnailGenerator.cs
index fdcfafd..3005546 100644
--- a/src/ThumbnailGenerator.cs
+++ b/src/ThumbnailGenerator.cs
@@ -38,8 +38,8 @@ namespace FSpot {
Gnome.Vfs.FileInfo vfs = new Gnome.Vfs.FileInfo (UriUtils.UriToStringEscaped (uri));
DateTime mtime = vfs.Mtime;
- PixbufUtils.SetOption (thumb, ThumbUri, UriUtils.UriToStringEscaped (uri));
- PixbufUtils.SetOption (thumb, ThumbMTime, ((uint)GLib.Marshaller.DateTimeTotime_t (mtime)).ToString ());
+ FSpot.Utils.PixbufUtils.SetOption (thumb, ThumbUri, UriUtils.UriToStringEscaped (uri));
+ FSpot.Utils.PixbufUtils.SetOption (thumb, ThumbMTime, ((uint)GLib.Marshaller.DateTimeTotime_t (mtime)).ToString ());
} catch (System.Exception e) {
Log.Exception (e);
}
diff --git a/src/UI.Dialog/EditTagIconDialog.cs b/src/UI.Dialog/EditTagIconDialog.cs
index 89e8b4f..43808f1 100644
--- a/src/UI.Dialog/EditTagIconDialog.cs
+++ b/src/UI.Dialog/EditTagIconDialog.cs
@@ -191,8 +191,7 @@ namespace FSpot.UI.Dialog
using (var tmp = new Gdk.Pixbuf (image_view.Pixbuf, x, y, width, height)) {
Gdk.Pixbuf transformed = FSpot.Utils.PixbufUtils.TransformOrientation (tmp, image_view.PixbufOrientation);
PreviewPixbuf = PixbufUtils.TagIconFromPixbuf (transformed);
- if (transformed != tmp)
- transformed.Dispose ();
+ transformed.Dispose ();
}
} else {
Gdk.Pixbuf transformed = FSpot.Utils.PixbufUtils.TransformOrientation (image_view.Pixbuf, image_view.PixbufOrientation);
diff --git a/src/Utils/PixbufUtils.cs b/src/Utils/PixbufUtils.cs
index c391fe1..68ff5d4 100644
--- a/src/Utils/PixbufUtils.cs
+++ b/src/Utils/PixbufUtils.cs
@@ -6,10 +6,12 @@
// Larry Ewing <lewing novell com>
// Stephane Delcroix <stephane declroix org>
//
-// This is free softwae. See cOPYING for details
+// This is free software. See COPYING for details
//
using Gdk;
+using System;
+using System.Runtime.InteropServices;
namespace FSpot.Utils
{
@@ -156,7 +158,7 @@ namespace FSpot.Utils
switch (orientation) {
default:
case PixbufOrientation.TopLeft:
- dest = src;
+ dest = PixbufUtils.ShallowCopy (src);
break;
case PixbufOrientation.TopRight:
dest = src.Flip (false);
@@ -187,5 +189,38 @@ namespace FSpot.Utils
return dest;
}
+
+ public static Pixbuf ShallowCopy (Pixbuf pixbuf)
+ {
+ if (pixbuf == null)
+ return null;
+ Pixbuf result = new Pixbuf (pixbuf, 0, 0, pixbuf.Width, pixbuf.Height);
+ CopyThumbnailOptions (pixbuf, result);
+ return result;
+ }
+
+ //
+ // FIXME this is actually not public api and we should do a verison check,
+ // but frankly I'm irritated that it isn't public so I don't much care.
+ //
+ [DllImport("libgdk_pixbuf-2.0-0.dll")]
+ static extern bool gdk_pixbuf_set_option(IntPtr raw, string key, string value);
+
+ public static bool SetOption(Gdk.Pixbuf pixbuf, string key, string value)
+ {
+
+ if (value != null)
+ return gdk_pixbuf_set_option(pixbuf.Handle, key, value);
+ else
+ return false;
+ }
+
+ public static void CopyThumbnailOptions (Gdk.Pixbuf src, Gdk.Pixbuf dest)
+ {
+ if (src != null && dest != null) {
+ PixbufUtils.SetOption (dest, "tEXt::Thumb::URI", src.GetOption ("tEXt::Thumb::URI"));
+ PixbufUtils.SetOption (dest, "tEXt::Thumb::MTime", src.GetOption ("tEXt::Thumb::MTime"));
+ }
+ }
}
}
diff --git a/src/Widgets/IconView.cs b/src/Widgets/IconView.cs
index 7ea6a6f..da8733f 100644
--- a/src/Widgets/IconView.cs
+++ b/src/Widgets/IconView.cs
@@ -843,7 +843,7 @@ namespace FSpot.Widgets
InterpType.Bilinear);
}
- PixbufUtils.CopyThumbnailOptions (thumbnail, temp_thumbnail);
+ FSpot.Utils.PixbufUtils.CopyThumbnailOptions (thumbnail, temp_thumbnail);
} else
temp_thumbnail = thumbnail;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]