* Brush.cs: Fixed Dispose method.
* SolidBrush.cs: Fixed Dispose method.
svn path=/trunk/mcs/; revision=28607
public abstract class Brush : MarshalByRefObject, ICloneable, IDisposable
{
internal IntPtr nativeObject;
+ internal bool disposed = false;
abstract public object Clone ();
internal Brush ()
protected virtual void Dispose (bool disposing)
{
- Status status = GDIPlus.GdipDeleteBrush (nativeObject);
- GDIPlus.CheckStatus (status);
+ if (disposed == false) {
+ Status status = GDIPlus.GdipDeleteBrush (nativeObject);
+ GDIPlus.CheckStatus (status);
+ disposed = true;
+ }
}
~Brush ()
+2004-06-01 Ravindra <rkumar@novell.com>
+
+ * Pen.cs: Added a note on Dispose method.
+ * Brush.cs: Fixed Dispose method.
+ * SolidBrush.cs: Fixed Dispose method.
+
2004-05-28 Ravindra <rkumar@novell.com>
* gdipFunctions.cs: Added some P/Invoke calls for Draw/Fill
void Dispose (bool disposing)
{
- // Let the GC collect it
+ // Pen is disposed if and only if it is not disposed and
+ // it is modifiable OR it is not disposed and it is being
+ // collected by GC.
if ((disposed == false) && (isModifiable || disposing == false)) {
Status status = GDIPlus.GdipDeletePen (nativeObject);
GDIPlus.CheckStatus (status);
protected override void Dispose (bool disposing)
{
- // Let the GC collect it
- if (isModifiable || disposing == false) {
+ // SolidBrush is disposed if and only if it is not disposed
+ // and it is modifiable OR it is not disposed and it is being
+ // collected by GC.
+ if ((disposed == false) && (isModifiable || disposing == false)) {
Status status = GDIPlus.GdipDeleteBrush (nativeObject);
GDIPlus.CheckStatus (status);
+ disposed = true;
}
else
throw new ArgumentException ("This SolidBrush object can't be modified.");