[f-spot/taglib-metadata: 3/20] More resource disposal.
- From: Ruben Vermeersch <rubenv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [f-spot/taglib-metadata: 3/20] More resource disposal.
- Date: Sat, 26 Jun 2010 19:36:20 +0000 (UTC)
commit fc65fbaeefb38a4fe56296eb9c6abf16e5260d46
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]