mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 01:59:12 +02:00
IDEIntf: TCollectionPropertyEditor: fixed unselecting if owner is freed
git-svn-id: trunk@40728 -
This commit is contained in:
parent
b6b3685433
commit
3f7db4aa7f
@ -32,6 +32,7 @@ type
|
|||||||
procedure FormDestroy(Sender: TObject);
|
procedure FormDestroy(Sender: TObject);
|
||||||
private
|
private
|
||||||
FCollection: TCollection;
|
FCollection: TCollection;
|
||||||
|
FOwnerComponent: TPersistent;
|
||||||
FOwnerPersistent: TPersistent;
|
FOwnerPersistent: TPersistent;
|
||||||
FPropertyName: String;
|
FPropertyName: String;
|
||||||
protected
|
protected
|
||||||
@ -49,6 +50,7 @@ type
|
|||||||
procedure Modified;
|
procedure Modified;
|
||||||
public
|
public
|
||||||
property Collection: TCollection read FCollection;
|
property Collection: TCollection read FCollection;
|
||||||
|
property OwnerComponent: TPersistent read FOwnerComponent;
|
||||||
property OwnerPersistent: TPersistent read FOwnerPersistent;
|
property OwnerPersistent: TPersistent read FOwnerPersistent;
|
||||||
property PropertyName: String read FPropertyName;
|
property PropertyName: String read FPropertyName;
|
||||||
end;
|
end;
|
||||||
@ -61,6 +63,11 @@ uses
|
|||||||
Controls, Dialogs, LCLProc, IDEImagesIntf, ObjInspStrConsts, PropEdits,
|
Controls, Dialogs, LCLProc, IDEImagesIntf, ObjInspStrConsts, PropEdits,
|
||||||
PropEditUtils;
|
PropEditUtils;
|
||||||
|
|
||||||
|
type
|
||||||
|
TPersistentAccess = class(TPersistent)
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCollectionPropertyEditorForm.FormCreate(Sender: TObject);
|
procedure TCollectionPropertyEditorForm.FormCreate(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
ToolBar1.Images := IDEImages.Images_16;
|
ToolBar1.Images := IDEImages.Images_16;
|
||||||
@ -244,7 +251,7 @@ procedure TCollectionPropertyEditorForm.PersistentDeleting(APersistent: TPersist
|
|||||||
var
|
var
|
||||||
AIndex, I: Integer;
|
AIndex, I: Integer;
|
||||||
begin
|
begin
|
||||||
if APersistent = OwnerPersistent then
|
if (APersistent = OwnerPersistent) or (APersistent = OwnerComponent) then
|
||||||
begin
|
begin
|
||||||
SetCollection(nil, nil, '');
|
SetCollection(nil, nil, '');
|
||||||
Hide;
|
Hide;
|
||||||
@ -348,6 +355,14 @@ begin
|
|||||||
FCollection := NewCollection;
|
FCollection := NewCollection;
|
||||||
FOwnerPersistent := NewOwnerPersistent;
|
FOwnerPersistent := NewOwnerPersistent;
|
||||||
FPropertyName := NewPropName;
|
FPropertyName := NewPropName;
|
||||||
|
//find the component that owns the collection
|
||||||
|
FOwnerComponent := NewOwnerPersistent;
|
||||||
|
while FOwnerComponent <> nil do
|
||||||
|
begin
|
||||||
|
if FOwnerComponent is TComponent then
|
||||||
|
break;
|
||||||
|
FOwnerComponent := TPersistentAccess(FOwnerComponent).GetOwner;
|
||||||
|
end;
|
||||||
//debugln('TCollectionPropertyEditorForm.SetCollection A Collection=',dbgsName(FCollection),' OwnerPersistent=',dbgsName(OwnerPersistent),' PropName=',PropertyName);
|
//debugln('TCollectionPropertyEditorForm.SetCollection A Collection=',dbgsName(FCollection),' OwnerPersistent=',dbgsName(OwnerPersistent),' PropName=',PropertyName);
|
||||||
if GlobalDesignHook <> nil then
|
if GlobalDesignHook <> nil then
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user