Fixed crash when deleting ShellTreeview or ShellListView from a form when the ShellListView or ShellTreeView properties are assigned

git-svn-id: trunk@32632 -
This commit is contained in:
andrew 2011-10-02 22:46:37 +00:00
parent 48cbedc75e
commit 32c6e290a3

View File

@ -309,13 +309,24 @@ begin
procedure TCustomShellTreeView.SetShellListView( procedure TCustomShellTreeView.SetShellListView(
const Value: TCustomShellListView); const Value: TCustomShellListView);
var
Tmp: TCustomShellListView;
begin begin
if FShellListView = Value then Exit;
if Assigned(FShellListView) and Assigned(Value) then
begin
Tmp := FShellListView;
FShellListView := nil;
Tmp.ShellTreeView := nil;
end;
FShellListView := Value; FShellListView := Value;
// Update the pair, it will then update itself // Update the pair, it will then update itself
// in the setter of this property // in the setter of this property
// Updates only if necessary to avoid circular calls of the setters // Updates only if necessary to avoid circular calls of the setters
if Value.ShellTreeView <> Self then if Assigned(Value) and (Value.ShellTreeView <> Self) then
Value.ShellTreeView := Self; Value.ShellTreeView := Self;
end; end;
@ -373,6 +384,7 @@ end;
destructor TCustomShellTreeView.Destroy; destructor TCustomShellTreeView.Destroy;
begin begin
ShellListView := nil;
inherited Destroy; inherited Destroy;
end; end;
@ -667,22 +679,30 @@ end;
procedure TCustomShellListView.SetShellTreeView( procedure TCustomShellListView.SetShellTreeView(
const Value: TCustomShellTreeView); const Value: TCustomShellTreeView);
var
Tmp: TCustomShellTreeView;
begin begin
if FShellTreeView <> Value then if FShellTreeView = Value then Exit;
if FShellTreeView <> nil then
begin begin
FShellTreeView := Value; Tmp := FShellTreeView;
FShellTreeView := nil;
Clear; Tmp.ShellListView := nil;
end;
if Value <> nil then
begin FShellTreeView := Value;
FRoot := Value.GetPathFromNode(Value.Selected);
PopulateWithRoot(); Clear;
end;
if Value <> nil then
begin
FRoot := Value.GetPathFromNode(Value.Selected);
PopulateWithRoot();
// Also update the pair, but only if necessary to avoid circular calls of the setters
if Value.ShellListView <> Self then Value.ShellListView := Self;
end; end;
// Also update the pair, but only if necessary to avoid circular calls of the setters
if Value.ShellListView <> Self then Value.ShellListView := Self;
end; end;
procedure TCustomShellListView.SetMask(const AValue: string); procedure TCustomShellListView.SetMask(const AValue: string);
@ -727,7 +747,7 @@ end;
destructor TCustomShellListView.Destroy; destructor TCustomShellListView.Destroy;
begin begin
ShellTreeView := nil;
inherited Destroy; inherited Destroy;
end; end;