Browse Source

Check visual parent is not already set.

When setting the visual parent of a control, make sure that it's not
already set. The code in issue #513 was trying to reparent an already
parented control, causing problems - this makes sure that this can't
happen.
pull/541/head
Steven Kirk 10 years ago
parent
commit
ab60beaa54
  1. 5
      src/Avalonia.SceneGraph/Visual.cs

5
src/Avalonia.SceneGraph/Visual.cs

@ -442,6 +442,11 @@ namespace Avalonia
/// <param name="value">The visual parent.</param> /// <param name="value">The visual parent.</param>
private void SetVisualParent(Visual value) private void SetVisualParent(Visual value)
{ {
if (value != null && _visualParent != null)
{
throw new InvalidOperationException("The control already has a visual parent.");
}
if (_visualParent == value) if (_visualParent == value)
{ {
return; return;

Loading…
Cancel
Save