From 249a13fc828d50275a72a91ccd1aff5e8d9e33ce Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Tue, 5 Apr 2005 16:45:47 +0000 Subject: [PATCH] * gdk/PixbufLoader.custom: Fix the new constructors to make sure they call Close() in the event of an exception, to prevent a g_warning. svn path=/trunk/gtk-sharp/; revision=42577 --- ChangeLog | 6 ++++++ gdk/PixbufLoader.custom | 30 +++++++++++++++++------------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 115c78206..ab7cf4ce4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-04-05 Dan Winship + + * gdk/PixbufLoader.custom: Fix the new constructors to make sure + they call Close() in the event of an exception, to prevent a + g_warning. + 2005-04-05 Mike Kestner * gtk/DestroyHelper.cs : implement an internal DestroyNotify handler diff --git a/gdk/PixbufLoader.custom b/gdk/PixbufLoader.custom index e973329c7..4e60246a8 100644 --- a/gdk/PixbufLoader.custom +++ b/gdk/PixbufLoader.custom @@ -48,33 +48,37 @@ while ((n = input.Read (buffer, 0, 8192)) != 0) Write (buffer, (uint) n); - Close (); } public PixbufLoader (System.IO.Stream stream) : this () { - LoadFromStream (stream); + try { + LoadFromStream (stream); + } finally { + Close (); + } } public PixbufLoader (System.Reflection.Assembly assembly, string resource) : this () { - if (assembly == null) - assembly = System.Reflection.Assembly.GetCallingAssembly (); + try { + if (assembly == null) + assembly = System.Reflection.Assembly.GetCallingAssembly (); - if (resource == null) - throw new ArgumentNullException ("resource"); + if (resource == null) + throw new ArgumentNullException ("resource"); - System.IO.Stream s = assembly.GetManifestResourceStream (resource); - if (s == null) - throw new ArgumentException ("'" + resource + "' is not a valid resource name of assembly '" + assembly + "'."); + System.IO.Stream s = assembly.GetManifestResourceStream (resource); + if (s == null) + throw new ArgumentException ("'" + resource + "' is not a valid resource name of assembly '" + assembly + "'."); - LoadFromStream (s); + LoadFromStream (s); + } finally { + Close (); + } } static public PixbufLoader LoadFromResource (string resource) { - if (resource == null) - throw new ArgumentNullException ("resource"); - return new PixbufLoader (System.Reflection.Assembly.GetCallingAssembly (), resource); }