mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-26 15:53:52 +02:00
ide: fix memory corruptions after showing codetools define preview dialog (bug #0012978)
git-svn-id: trunk@18311 -
This commit is contained in:
parent
5714e4dadc
commit
74b347b39f
@ -213,48 +213,43 @@ begin
|
||||
exit;
|
||||
end;
|
||||
|
||||
Defines:=nil;
|
||||
// set our debug function, clear codetools cache and calculate the values
|
||||
if FNodeValues<>nil then
|
||||
FNodeValues.FreeAndClear;
|
||||
DefineTree.ClearCache;// make sure the defines are reparsed
|
||||
|
||||
OldOnCalculate:=DefineTree.OnCalculate;
|
||||
DefineTree.OnCalculate:=@DefineTreeCalculate;
|
||||
try
|
||||
|
||||
// set our debug function, clear codetools cache and calculate the values
|
||||
if FNodeValues<>nil then
|
||||
FNodeValues.FreeAndClear;
|
||||
DefineTree.ClearCache;// make sure the defines are reparsed
|
||||
OldOnCalculate:=DefineTree.OnCalculate;
|
||||
DefineTree.OnCalculate:=@DefineTreeCalculate;
|
||||
try
|
||||
Defines:=DefineTree.GetDefinesForDirectory(Dir,false);
|
||||
finally
|
||||
DefineTree.OnCalculate:=OldOnCalculate;
|
||||
end;
|
||||
|
||||
// fill the ValuesListview
|
||||
ValuesListview.BeginUpdate;
|
||||
if Defines<>nil then begin
|
||||
for i:=0 to Defines.Count-1 do begin
|
||||
if ValuesListview.Items.Count<=i then
|
||||
ListItem:=ValuesListview.Items.Add
|
||||
else
|
||||
ListItem:=ValuesListview.Items[i];
|
||||
ListItem.Caption:=Defines.Names(i);
|
||||
Value:=Defines.Values(i);
|
||||
if length(Value)>100 then
|
||||
Value:=copy(Value,1,100)+' ...';
|
||||
if ListItem.SubItems.Count<1 then
|
||||
ListItem.SubItems.Add(Value)
|
||||
else
|
||||
ListItem.SubItems[0]:=Value;
|
||||
end;
|
||||
while ValuesListview.Items.Count>Defines.Count do
|
||||
ValuesListview.Items.Delete(ValuesListview.Items.Count-1);
|
||||
end else begin
|
||||
ValuesListview.Items.Clear;
|
||||
end;
|
||||
ValuesListview.EndUpdate;
|
||||
UpdateValue;
|
||||
Defines:=DefineTree.GetDefinesForDirectory(Dir,false);
|
||||
finally
|
||||
Defines.Free;
|
||||
DefineTree.OnCalculate:=OldOnCalculate;
|
||||
end;
|
||||
|
||||
// fill the ValuesListview
|
||||
ValuesListview.BeginUpdate;
|
||||
if Defines<>nil then begin
|
||||
for i:=0 to Defines.Count-1 do begin
|
||||
if ValuesListview.Items.Count<=i then
|
||||
ListItem:=ValuesListview.Items.Add
|
||||
else
|
||||
ListItem:=ValuesListview.Items[i];
|
||||
ListItem.Caption:=Defines.Names(i);
|
||||
Value:=Defines.Values(i);
|
||||
if length(Value)>100 then
|
||||
Value:=copy(Value,1,100)+' ...';
|
||||
if ListItem.SubItems.Count<1 then
|
||||
ListItem.SubItems.Add(Value)
|
||||
else
|
||||
ListItem.SubItems[0]:=Value;
|
||||
end;
|
||||
while ValuesListview.Items.Count>Defines.Count do
|
||||
ValuesListview.Items.Delete(ValuesListview.Items.Count-1);
|
||||
end else begin
|
||||
ValuesListview.Items.Clear;
|
||||
end;
|
||||
ValuesListview.EndUpdate;
|
||||
UpdateValue;
|
||||
end;
|
||||
|
||||
procedure TCodeToolsDefinesDialog.UpdateValue;
|
||||
|
Loading…
Reference in New Issue
Block a user