* 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
This commit is contained in:
Dan Winship 2005-04-05 16:45:47 +00:00
parent 23ec73d6f9
commit 249a13fc82
2 changed files with 23 additions and 13 deletions

View File

@ -1,3 +1,9 @@
2005-04-05 Dan Winship <danw@novell.com>
* 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 <mkestner@novell.com>
* gtk/DestroyHelper.cs : implement an internal DestroyNotify handler

View File

@ -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);
}