[f-spot/taglib-metadata: 3/5] More resource disposal.
- From: Ruben Vermeersch <rubenv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [f-spot/taglib-metadata: 3/5] More resource disposal.
- Date: Fri, 11 Jun 2010 21:08:46 +0000 (UTC)
commit 370da8ffe57c3a095d96c4a7d201eaf0b652793c
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 2a65937..edec9f7 100644
--- a/src/Imaging/JpegFile.cs
+++ b/src/Imaging/JpegFile.cs
@@ -24,6 +24,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]