Author: jordi
Date: 2005-04-04 07:23:49 -0400 (Mon, 04 Apr 2005)
New Revision: 42509

Modified:
   trunk/mcs/class/System.Drawing/System.Drawing.Text/FontCollection.cs
   trunk/mcs/class/System.Drawing/System.Drawing.Text/PrivateFontCollection.cs
   trunk/mcs/class/System.Drawing/System.Drawing.Text/changelog
   trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog
   trunk/mcs/class/System.Drawing/System.Drawing/Color.cs
   trunk/mcs/class/System.Drawing/System.Drawing/Font.cs
   trunk/mcs/class/System.Drawing/System.Drawing/FontFamily.cs
Log:
2005-04-04 Jordi Mas i Hernandez <[EMAIL PROTECTED]>

        * Color.cs: take into account the name color in == and != operators
        * Font.cs: Use Equals instead of == to compare the family name
        * FontFamily.cs:
           -  Removes generic fontfamilies cache (done at libgdiplus level)
           -  Fixes Equals method



Modified: trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog
===================================================================
--- trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog     2005-04-04 
10:48:49 UTC (rev 42508)
+++ trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog     2005-04-04 
11:23:49 UTC (rev 42509)
@@ -1,3 +1,11 @@
+2005-04-04 Jordi Mas i Hernandez <[EMAIL PROTECTED]>
+
+       * Color.cs: take into account the name color in == and != operators
+       * Font.cs: Use Equals instead of == to compare the family name
+       * FontFamily.cs:
+          -  Removes generic fontfamilies cache (done at libgdiplus level)
+          -  Fixes Equals method
+
 2005-03-30 Jordi Mas i Hernandez <[EMAIL PROTECTED]>
 
        * Pen.cs: remove locks. They are done at gdiplus level

Modified: trunk/mcs/class/System.Drawing/System.Drawing/Color.cs
===================================================================
--- trunk/mcs/class/System.Drawing/System.Drawing/Color.cs      2005-04-04 
10:48:49 UTC (rev 42508)
+++ trunk/mcs/class/System.Drawing/System.Drawing/Color.cs      2005-04-04 
11:23:49 UTC (rev 42509)
@@ -271,7 +271,8 @@
                public static bool operator == (Color colorA, Color colorB)
                {
                        return ((colorA.a == colorB.a) && (colorA.r == colorB.r)
-                       && (colorA.g == colorB.g) && (colorA.b == colorB.b));
+                       && (colorA.g == colorB.g) && (colorA.b == colorB.b) &&
+                       (colorA.myname == colorB.myname));
                }
                
                /// <summary>
@@ -287,7 +288,8 @@
                public static bool operator != (Color colorA, Color colorB)
                {
                        return ((colorA.a != colorB.a) || (colorA.r != colorB.r)
-                       || (colorA.g != colorB.g) || (colorA.b != colorB.b));
+                       || (colorA.g != colorB.g) || (colorA.b != colorB.b) &&
+                       (colorA.myname != colorB.myname));
                }
 
                // This gives the right results, but the floats don't exactly 
match MS

Modified: trunk/mcs/class/System.Drawing/System.Drawing/Font.cs
===================================================================
--- trunk/mcs/class/System.Drawing/System.Drawing/Font.cs       2005-04-04 
10:48:49 UTC (rev 42508)
+++ trunk/mcs/class/System.Drawing/System.Drawing/Font.cs       2005-04-04 
11:23:49 UTC (rev 42509)
@@ -471,9 +471,9 @@
                        if (! (obj is Font))
                                return false;
                                
-                       Font fnt = (Font) obj;
+                       Font fnt = (Font) obj;                  
                        
-                       if (fnt.FontFamily == FontFamily && fnt.Size == Size &&
+                       if (fnt.FontFamily.Equals (FontFamily) && fnt.Size == 
Size &&
                            fnt.Style == Style && fnt.Unit == Unit &&
                            fnt.GdiCharSet == GdiCharSet && 
                            fnt.GdiVerticalFont == GdiVerticalFont)

Modified: trunk/mcs/class/System.Drawing/System.Drawing/FontFamily.cs
===================================================================
--- trunk/mcs/class/System.Drawing/System.Drawing/FontFamily.cs 2005-04-04 
10:48:49 UTC (rev 42508)
+++ trunk/mcs/class/System.Drawing/System.Drawing/FontFamily.cs 2005-04-04 
11:23:49 UTC (rev 42509)
@@ -141,15 +141,12 @@
                {
                        get 
                        {
-                               if (genericMonospace == null) 
-                               {
-                                       IntPtr generic = IntPtr.Zero;
-                                       Status status = 
GDIPlus.GdipGetGenericFontFamilyMonospace (out generic);
-                                       GDIPlus.CheckStatus (status);
-                                       genericMonospace = new FontFamily 
(generic);                                            
-                                       genericMonospace.refreshName ();
-                                       
-                               }
+                               
+                               IntPtr generic = IntPtr.Zero;
+                               Status status = 
GDIPlus.GdipGetGenericFontFamilyMonospace (out generic);
+                               GDIPlus.CheckStatus (status);
+                               FontFamily genericMonospace = new FontFamily 
(generic);                                         
+                               genericMonospace.refreshName ();
                                return genericMonospace;
                        }
                }
@@ -158,15 +155,11 @@
                {
                        get 
                        {
-                               if (genericSansSerif == null) 
-                               {
-                                       IntPtr generic = IntPtr.Zero;
-                                       Status status = 
GDIPlus.GdipGetGenericFontFamilySansSerif (out generic);
-                                       GDIPlus.CheckStatus (status);
-                                       genericSansSerif = new FontFamily 
(generic);
-                                       genericSansSerif.refreshName ();
-                                       
-                               }
+                               IntPtr generic = IntPtr.Zero;
+                               Status status = 
GDIPlus.GdipGetGenericFontFamilySansSerif (out generic);
+                               GDIPlus.CheckStatus (status);
+                               FontFamily genericSansSerif = new FontFamily 
(generic);
+                               genericSansSerif.refreshName ();
                                return genericSansSerif;
                        }
                }
@@ -175,14 +168,11 @@
                {
                        get 
                        {
-                               if (genericSerif == null) 
-                               {
-                                       IntPtr generic = IntPtr.Zero;
-                                       Status status = 
GDIPlus.GdipGetGenericFontFamilySerif (out generic);
-                                       GDIPlus.CheckStatus (status);
-                                       genericSerif = new FontFamily (generic);
-                                       genericSerif.refreshName ();
-                               }
+                               IntPtr generic = IntPtr.Zero;
+                               Status status = 
GDIPlus.GdipGetGenericFontFamilySerif (out generic);
+                               GDIPlus.CheckStatus (status);
+                               FontFamily genericSerif = new FontFamily 
(generic);
+                               genericSerif.refreshName ();                    
        
                                return genericSerif;
                        }
                }
@@ -279,8 +269,9 @@
                {
                        if (!(obj is FontFamily))
                                return false;
-
-                       return (this == (FontFamily) obj);                      
+                               
+                       FontFamily o = (FontFamily) obj;
+                       return (nativeFontFamily == o.nativeFontFamily);        
                
                }
                
                public override int GetHashCode ()

Modified: trunk/mcs/class/System.Drawing/System.Drawing.Text/FontCollection.cs
===================================================================
--- trunk/mcs/class/System.Drawing/System.Drawing.Text/FontCollection.cs        
2005-04-04 10:48:49 UTC (rev 42508)
+++ trunk/mcs/class/System.Drawing/System.Drawing.Text/FontCollection.cs        
2005-04-04 11:23:49 UTC (rev 42509)
@@ -50,6 +50,8 @@
                // methods
                public void Dispose()
                {
+                       Dispose (true);
+                       GC.SuppressFinalize (true);
                }
 
                protected virtual void Dispose (bool disposing)
@@ -65,7 +67,7 @@
                                Status status;
                                FontFamily[] families;
                                
-                               status = 
GDIPlus.GdipGetFontCollectionFamilyCount (nativeFontCollection, out found);
+                               status = 
GDIPlus.GdipGetFontCollectionFamilyCount (nativeFontCollection, out found);
                                GDIPlus.CheckStatus (status);
                                
                                int nSize =  Marshal.SizeOf (IntPtr.Zero);

Modified: 
trunk/mcs/class/System.Drawing/System.Drawing.Text/PrivateFontCollection.cs
===================================================================
--- trunk/mcs/class/System.Drawing/System.Drawing.Text/PrivateFontCollection.cs 
2005-04-04 10:48:49 UTC (rev 42508)
+++ trunk/mcs/class/System.Drawing/System.Drawing.Text/PrivateFontCollection.cs 
2005-04-04 11:23:49 UTC (rev 42509)
@@ -71,9 +71,11 @@
                protected override void Dispose(bool disposing)
                {
                        if (nativeFontCollection!=IntPtr.Zero){                 
        
-                               GDIPlus.GdipDeletePrivateFontCollection 
(nativeFontCollection);                 
-                               GC.SuppressFinalize(this);
+                               GDIPlus.GdipDeletePrivateFontCollection 
(nativeFontCollection);                                                 
+                               nativeFontCollection = IntPtr.Zero;
                        }
+                       
+                       base.Dispose (true);
                }               
                
 

Modified: trunk/mcs/class/System.Drawing/System.Drawing.Text/changelog
===================================================================
--- trunk/mcs/class/System.Drawing/System.Drawing.Text/changelog        
2005-04-04 10:48:49 UTC (rev 42508)
+++ trunk/mcs/class/System.Drawing/System.Drawing.Text/changelog        
2005-04-04 11:23:49 UTC (rev 42509)
@@ -1,7 +1,14 @@
+2005-04-04  Jordi Mas i Hernandez <[EMAIL PROTECTED]>
+
+       * PrivateFontCollection.cs: nativeFontCollection equals IntPtr.Zero to
+       avoid errors on multiple disposes
+       
+       * FontCollection.cs: implements dispose
+
 2004-11-25  Marek Safar  <[EMAIL PROTECTED]>
 
-       * Image.cs: Add CheckStatus to Families.
-
+       * Image.cs: Add CheckStatus to Families.
+
 2004-02-25  Andreas Nahr <[EMAIL PROTECTED]>
 
        * PrivateFontCollection.cs: Removed excess attributes

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

Reply via email to