Permalink
Browse files

2006-10-11 Sebastien Pouliot <sebastien@ximian.com>

	* Graphics.cs: In MeasureCharacterRanges throw an ArgumentException if
	StringFormat is null and return an empty region array if no range exists 
	(avoid GDI+ error/exeception). In MeasureString (2 overloads) replace 
	999999 by Int32.MaxValue (now that the real bug is fixed).
	* StringFormat.cs: Ensure we are clearing the handle before throwing
	any exception.


svn path=/trunk/mcs/; revision=66590
  • Loading branch information...
1 parent b3bdf58 commit fd5a4123ae26b3203e90100e4ecc1d477a96d6b3 Sebastien Pouliot committed Oct 12, 2006
@@ -1,3 +1,12 @@
+2006-10-11 Sebastien Pouliot <sebastien@ximian.com>
+
+ * Graphics.cs: In MeasureCharacterRanges throw an ArgumentException if
+ StringFormat is null and return an empty region array if no range exists
+ (avoid GDI+ error/exeception). In MeasureString (2 overloads) replace
+ 999999 by Int32.MaxValue (now that the real bug is fixed).
+ * StringFormat.cs: Ensure we are clearing the handle before throwing
+ any exception.
+
2006-09-21 Sebastien Pouliot <sebastien@ximian.com>
* gdipFunctions.cs: Throw an OverflowException for the ValueOverflow
@@ -5,10 +5,10 @@
// Gonzalo Paniagua Javier (gonzalo@ximian.com) (stubbed out)
// Alexandre Pigolkine(pigolkine@gmx.de)
// Jordi Mas i Hernandez (jordi@ximian.com)
+// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2003 Ximian, Inc. (http://www.ximian.com)
-//
-// Copyright (C) 2004-2005 Novell, Inc. (http://www.novell.com)
+// Copyright (C) 2004-2006 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -1884,9 +1884,12 @@ public Region[] MeasureCharacterRanges (string text, Font font, RectangleF layou
throw new ArgumentNullException ("font");
if (stringFormat == null)
- stringFormat = StringFormat.GenericDefault;
+ throw new ArgumentException ("stringFormat");
int regcount = stringFormat.GetMeasurableCharacterRangeCount ();
+ if (regcount == 0)
+ return new Region[0];
+
IntPtr[] native_regions = new IntPtr [regcount];
Region[] regions = new Region [regcount];
@@ -1940,7 +1943,7 @@ public SizeF MeasureString (string text, Font font, int width)
throw new ArgumentNullException ("font");
RectangleF boundingBox = new RectangleF ();
- RectangleF rect = new RectangleF (0, 0, width, 999999);
+ RectangleF rect = new RectangleF (0, 0, width, Int32.MaxValue);
int charactersFitted, linesFilled;
Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
@@ -1965,7 +1968,7 @@ public SizeF MeasureString (string text, Font font, int width)
public SizeF MeasureString (string text, Font font, int width, StringFormat format)
{
int charactersFitted, linesFilled;
- return MeasureString (text, font, new SizeF (width, 999999),
+ return MeasureString (text, font, new SizeF (width, Int32.MaxValue),
format, out charactersFitted, out linesFilled);
}
@@ -70,9 +70,8 @@ void Dispose (bool disposing)
{
if (nativeStrFmt != IntPtr.Zero) {
Status status = GDIPlus.GdipDeleteStringFormat (nativeStrFmt);
- GDIPlus.CheckStatus (status);
-
nativeStrFmt = IntPtr.Zero;
+ GDIPlus.CheckStatus (status);
}
}

0 comments on commit fd5a412

Please sign in to comment.