[Mono-bugs] [Bug 56691][Nor] New - libgdiplus expects X display

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 8 Apr 2004 06:51:56 -0400 (EDT)

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by ximian@divinehawk.com.


--- shadow/56691	2004-04-08 06:51:56.000000000 -0400
+++ shadow/56691.tmp.8243	2004-04-08 06:51:56.000000000 -0400
@@ -0,0 +1,53 @@
+Bug#: 56691
+Product: Mono: Runtime
+Version: unspecified
+OS Details: 
+Status: NEW   
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: ximian@divinehawk.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+Summary: libgdiplus expects X display
+Trying to call Image.FromFile you'll get the following output:
+Stride: 960
+Scan0: 42465008
+System.NullReferenceException: A null value was found where an object
+instance was required.
+in (unmanaged) /usr/X11R6/lib/libX11.so.6(XGetDefault+0x34) [0x423a28b4]
+in (unmanaged) /usr/lib/libgdiplus.so(gdip_get_display_dpi+0x4d) [0x421c5b0d]
+in (unmanaged) /usr/lib/libgdiplus.so(gdip_image_init+0x49) [0x421cc779]
+in (unmanaged) /usr/lib/libgdiplus.so(gdip_bitmap_init+0x22) [0x421c3892]
+in (unmanaged) /usr/lib/libgdiplus.so(gdip_bitmap_new+0x2d) [0x421c396d]
+in (unmanaged) /usr/lib/libgdiplus.so(GdipCreateBitmapFromScan0+0x89)
+in <0x00044> (wrapper managed-to-native)
+in <0x001dc> System.Drawing.Bitmap:InitFromStream (System.IO.Stream)
+in <0x00056> (wrapper remoting-invoke-with-check)
+System.Drawing.Bitmap:InitFromStream (System.IO.Stream)
+in <0x0004f> System.Drawing.Bitmap:.ctor (string,bool)
+in <0x00012> System.Drawing.Bitmap:.ctor (string)
+in <0x00056> (wrapper remoting-invoke-with-check)
+System.Drawing.Bitmap:.ctor (string)
+in <0x00020> System.Drawing.Image:FromFile (string)
+in <0x00020> FOTQ.Capture:GetImage ()
+As you can see the problem is in gdip_get_display_dpi: 
+Display* display=XOpenDisplay(NULL);
+The return value of XOpenDisplay is not checked.
+The result is that if you don't have a valid X server to connect to then
+you will not be able to use System.Drawing. 
+The attached patch fixes gdip_get_display_dpi().