[f-spot] More resource disposal.
- From: Ruben Vermeersch <rubenv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [f-spot] More resource disposal.
- Date: Thu, 8 Jul 2010 16:49:56 +0000 (UTC)
commit 4a7dc7c4bff548f566ecfae6552ffe23d15c71f9
Author: Ruben Vermeersch <ruben savanne be>
Date: Sun May 16 12:28:38 2010 +0200
More resource disposal.
src/Imaging/JpegFile.cs | 4 ++++
src/Utils/GIOTagLibFileAbstraction.cs | 12 +++++++++++-
2 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/src/Imaging/JpegFile.cs b/src/Imaging/JpegFile.cs
index 7500663..dfb6b37 100644
--- a/src/Imaging/JpegFile.cs
+++ b/src/Imaging/JpegFile.cs
@@ -23,6 +23,10 @@ namespace FSpot {
metadata_file = TagLib.File.Create (new GIOTagLibFileAbstraction () { Uri = uri }) as Image.File;
}
+ ~JpegFile () {
+ metadata_file.Dispose ();
+ }
+
public override Cms.Profile GetProfile ()
{
return null;
diff --git a/src/Utils/GIOTagLibFileAbstraction.cs b/src/Utils/GIOTagLibFileAbstraction.cs
index 46a5626..c6240a3 100644
--- a/src/Utils/GIOTagLibFileAbstraction.cs
+++ b/src/Utils/GIOTagLibFileAbstraction.cs
@@ -6,6 +6,8 @@ namespace FSpot.Utils
{
public sealed class GIOTagLibFileAbstraction : TagLib.File.IFileAbstraction
{
+ private FileInputStream gio_stream;
+
public string Name {
get {
return Uri.ToString ();
@@ -18,7 +20,13 @@ namespace FSpot.Utils
public Uri Uri { get; set; }
public Stream ReadStream {
- get { return new GioStream (FileFactory.NewForUri(Uri).Read (null)); }
+ get {
+ if (gio_stream == null) {
+ var file = FileFactory.NewForUri(Uri);
+ gio_stream = file.Read (null);
+ }
+ return new GioStream (gio_stream);
+ }
}
public Stream WriteStream {
@@ -28,6 +36,8 @@ namespace FSpot.Utils
public void CloseStream (Stream stream)
{
stream.Close ();
+ gio_stream.Dispose ();
+ gio_stream = null;
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]