Author: pbartok
Date: 2006-05-15 14:10:58 -0400 (Mon, 15 May 2006)
New Revision: 60715
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
Log:
2006-05-15 Peter Dennis Bartok <[EMAIL PROTECTED]>
* Control.cs: Dispose all child controls when control is diposed
(#78394)
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-05-15 18:05:27 UTC (rev 60714)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-05-15 18:10:58 UTC (rev 60715)
@@ -1,3 +1,7 @@
+2006-05-15 Peter Dennis Bartok <[EMAIL PROTECTED]>
+
+ * Control.cs: Dispose all child controls when control is diposed
(#78394)
+
2006-05-14 Alexander Olk <[EMAIL PROTECTED]>
* ColorDialog.cs: Finally it is possible to select the color with
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
2006-05-15 18:05:27 UTC (rev 60714)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
2006-05-15 18:10:58 UTC (rev 60715)
@@ -732,24 +732,37 @@
private delegate void RemoveDelegate(object c);
protected override void Dispose(bool disposing) {
- if (dc_mem!=null) {
- dc_mem.Dispose();
- dc_mem=null;
- }
+ if (disposing) {
+ if (dc_mem!=null) {
+ dc_mem.Dispose();
+ dc_mem=null;
+ }
- if (bmp_mem!=null) {
- bmp_mem.Dispose();
- bmp_mem=null;
- }
+ if (bmp_mem!=null) {
+ bmp_mem.Dispose();
+ bmp_mem=null;
+ }
- if (this.InvokeRequired) {
- if (Application.MessageLoop) {
- this.BeginInvokeInternal(new
MethodInvoker(DestroyHandle), null, true);
- this.BeginInvokeInternal(new
RemoveDelegate(controls.Remove), new object[] {this}, true);
+ if (this.InvokeRequired) {
+ if (Application.MessageLoop) {
+ this.BeginInvokeInternal(new
MethodInvoker(DestroyHandle), null, true);
+ this.BeginInvokeInternal(new
RemoveDelegate(controls.Remove), new object[] {this}, true);
+ }
+ } else {
+ DestroyHandle();
+ controls.Remove(this);
}
- } else {
- DestroyHandle();
- controls.Remove(this);
+
+
+ if (parent != null) {
+ parent.Controls.Remove(this);
+ }
+
+ Control [] children =
child_controls.GetAllControls ();
+ for (int i=0; i<children.Length; i++) {
+ children[i].parent = null; // Need
to set to null or our child will try and remove from ourselves and crash
+ children[i].Dispose();
+ }
}
is_disposed = true;
base.Dispose(disposing);
@@ -3823,6 +3836,10 @@
paint_event =
XplatUI.PaintEventStart(Handle, true);
+ if (paint_event == null) {
+ return;
+ }
+
if (!needs_redraw) {
// Just blit the previous image
paint_event.Graphics.DrawImage
(ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle,
GraphicsUnit.Pixel);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches