Having a TSynAutocomplete on a form crashes lazarus, whenevr the
component is freed.
The attached patch fixes that.
At least it works around it, doesn't crash here anymore.
But there might be another bug "deeper inside":
It seems to me, that the notification method is called again after the
component is allready destroyed. Unfortunately, I can't really debug
this, as my system crashes badly, if I try ..
regards,
Burkhard
Index: components/synedit/syncompletion.pas
===================================================================
--- components/synedit/syncompletion.pas (Revision 9407)
+++ components/synedit/syncompletion.pas (Arbeitskopie)
@@ -1324,8 +1324,9 @@
Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
- if (Operation = opRemove) and (fEditors.IndexOf(AComponent) > -1) then
- RemoveEditor(AComponent as TCustomSynEdit);
+ if (Operation = opRemove) and (fEditors <> nil) then
+ if (fEditors.IndexOf(AComponent) > -1) then
+ RemoveEditor(AComponent as TCustomSynEdit);
end;
constructor TSynCompletion.Create(AOwner: TComponent);
@@ -1436,8 +1437,8 @@
Form := nil;
while fEditors.Count <> 0 do
RemoveEditor(TCustomSynEdit(fEditors.last));
- fEditors.Free;
- fEditstuffs.free;
+ FreeAndNil(fEditors);
+ FreeAndNil(fEditstuffs);
inherited;
end;
@@ -1545,9 +1546,9 @@
{$ELSE}
RemoveEditor(feditors.last);
{$ENDIF}
- fEditors.free;
- fEditstuffs.free;
- fAutoCompleteList.free;
+ FreeAndNil(fEditors);
+ FreeAndNil(fEditstuffs);
+ FreeAndNil(fAutoCompleteList);
inherited;
end;
@@ -1676,8 +1677,9 @@
procedure TSynAutoComplete.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
- if (Operation = opRemove) and (fEditors.indexOf(AComponent) <> -1) then
- RemoveEditor(AComponent as TCustomSynEdit);
+ if (Operation = opRemove) and (fEditors <> nil) then
+ if fEditors.indexOf(AComponent) <> -1 then
+ RemoveEditor(AComponent as TCustomSynEdit);
end;
function TSynAutoComplete.RemoveEditor(aEditor: TCustomSynEdit): boolean;