瀏覽代碼

* Remove component from previous owner. Fix issue #39529

Michaël Van Canneyt 3 年之前
父節點
當前提交
d6a26f2c28
共有 1 個文件被更改,包括 2 次插入0 次删除
  1. 2 0
      rtl/objpas/classes/compon.inc

+ 2 - 0
rtl/objpas/classes/compon.inc

@@ -603,6 +603,8 @@ Procedure TComponent.InsertComponent(AComponent: TComponent);
 begin
   AComponent.ValidateContainer(Self);
   ValidateRename(AComponent,'',AComponent.FName);
+  If AComponent.FOwner<>Nil then
+    AComponent.FOwner.Remove(AComponent);
   Insert(AComponent);
   AComponent.SetReference(True);
   If csDesigning in FComponentState then