Bug 19818

Summary: Parent changed when trying to remove control that is not a child control
Product: [Mono] Class Libraries Reporter: eb1
Component: Windows.FormsAssignee: Bugzilla <bugzilla>
Status: RESOLVED FIXED    
Severity: normal CC: miguel, mono-bugs+mono
Priority: ---    
Version: 3.4.0   
Target Milestone: Untriaged   
Hardware: PC   
OS: Linux   
Tags: Is this bug a regression?: ---
Last known good build:

Description eb1 2014-05-15 11:14:01 UTC
When trying to remove a control from a controls collections and the control is not part of the controls collection then nothing should happen. However the parent of the control still gets set to null.

var c1 = new Control();
var c2 = new Control();
var c3 = new Control();

c2.Controls.Add(c3);
c1.Controls.Add(c2);

Debug.Assert(c3.Parent == c2);

c1.Controls.Remove(c3);
Debug.Assert(c3.Parent == c2); // this assertion currently fails
Comment 1 eb1 2014-05-15 11:31:56 UTC
Suggested fix in PR #1038
Comment 2 Miguel de Icaza [MSFT] 2014-05-15 16:10:34 UTC
Thanks, the patch has been applied