2006-08-28 Jonathan Chambers <joncham@gmail.com>
authorJonathan Chambers <joncham@gmail.com>
Mon, 28 Aug 2006 18:54:46 +0000 (18:54 -0000)
committerJonathan Chambers <joncham@gmail.com>
Mon, 28 Aug 2006 18:54:46 +0000 (18:54 -0000)
* ComIStreamMarshaler.cs: Do not free memory allocated for
Com Callable Wrapper for stream. When Image created from stream
is destroyed, it calls Release on CCW interface. Somehow we seem
to be destroying Stream CCW before Image is destroyed. Fixes
crash on exit on Windows. #78315

svn path=/trunk/mcs/; revision=64485

mcs/class/System.Drawing/System.Drawing/ChangeLog
mcs/class/System.Drawing/System.Drawing/ComIStreamMarshaler.cs

index 2107cc54eefa81b80a9f5e6dfca3a5791c422dd7..e7a7cdc7446679a97f358fa0699c3cd951707cfd 100644 (file)
@@ -1,3 +1,11 @@
+2006-08-28  Jonathan Chambers  <joncham@gmail.com> 
+
+       * ComIStreamMarshaler.cs: Do not free memory allocated for
+       Com Callable Wrapper for stream. When Image created from stream
+       is destroyed, it calls Release on CCW interface. Somehow we seem
+       to be destroying Stream CCW before Image is destroyed. Fixes
+       crash on exit on Windows. #78315
+       
 2006-08-28     Boris Kirzner   <borisk@mainsoft.com>
 
        * SystemColors.jvm.cs: fix array size for NET_2_0
index efcd589e760b5300dd50d61a118b9b865e2b8b70..c2b4d1859aa893daeb16434f01b03d714a17a087 100644 (file)
@@ -177,7 +177,17 @@ namespace System.Drawing
 
                        private void Dispose(bool disposing)
                        {
-                               Marshal.FreeHGlobal(comInterface);
+                               // FIXME: This causes crash on windows on shutdown.
+                               // Any image loaded from a stream holds onto a reference
+                               // to that stream, and calls Release on the stream when the image is
+                               // disposed. Somehow, we are getting destroyed before the image is
+                               // even though we are using a GC handle (maybe GCHandles are ignored on shutdown)?
+                               // in any cause I think leaking a pointer per image for now is
+                               // better than crashing on windows.
+                               // Need to talk to Paolo about having an unmanaged resource (IStream) in one managed
+                               // object that another unmanaged resource (Image) in another managed object depends on.
+
+                               //Marshal.FreeHGlobal(comInterface);
                                gcHandle.Free();
                                if (disposing)
                                {