Author: danw
Date: 2005-04-05 12:45:47 -0400 (Tue, 05 Apr 2005)
New Revision: 42577

Modified:
   trunk/gtk-sharp/ChangeLog
   trunk/gtk-sharp/gdk/PixbufLoader.custom
Log:
        * gdk/PixbufLoader.custom: Fix the new constructors to make sure
        they call Close() in the event of an exception, to prevent a
        g_warning.


Modified: trunk/gtk-sharp/ChangeLog
===================================================================
--- trunk/gtk-sharp/ChangeLog   2005-04-05 15:27:55 UTC (rev 42576)
+++ trunk/gtk-sharp/ChangeLog   2005-04-05 16:45:47 UTC (rev 42577)
@@ -1,3 +1,9 @@
+2005-04-05  Dan Winship  <[EMAIL PROTECTED]>
+
+       * 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  <[EMAIL PROTECTED]>
 
        * gtk/DestroyHelper.cs : implement an internal DestroyNotify handler 

Modified: trunk/gtk-sharp/gdk/PixbufLoader.custom
===================================================================
--- trunk/gtk-sharp/gdk/PixbufLoader.custom     2005-04-05 15:27:55 UTC (rev 
42576)
+++ trunk/gtk-sharp/gdk/PixbufLoader.custom     2005-04-05 16:45:47 UTC (rev 
42577)
@@ -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);
                }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to