From 2d8389be3eba6ffaf10f641f88a5e323a30d5500 Mon Sep 17 00:00:00 2001 From: Niels Date: Mon, 24 May 2010 00:17:21 +0200 Subject: [PATCH] Fixed another (possible) memory leak in param hints --- Projects/Simba/framescript.pas | 2 +- Units/Misc/v_autocompleteform.pas | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Projects/Simba/framescript.pas b/Projects/Simba/framescript.pas index 087ce88..043dc55 100644 --- a/Projects/Simba/framescript.pas +++ b/Projects/Simba/framescript.pas @@ -426,7 +426,7 @@ begin if (d <> nil) then begin d := TciTypeKind(d).GetRealType; - if (d is TciReturnType) then + if (d <> nil) and (d is TciReturnType) then d := d.Owner; end; if (d <> nil) and (d.Owner <> nil) and (not ((d is TciProcedureDeclaration) or (d.Owner is TciProcedureDeclaration))) then diff --git a/Units/Misc/v_autocompleteform.pas b/Units/Misc/v_autocompleteform.pas index 35c1fb7..3ea6b63 100644 --- a/Units/Misc/v_autocompleteform.pas +++ b/Units/Misc/v_autocompleteform.pas @@ -614,7 +614,7 @@ var CursorXY : TPoint; begin result := -1; - if (FSynEdit = nil) or (FParameters = nil) then + if (FSynEdit = nil) then Exit; MustHide := True; Parser := TmwPasLex.Create; //The position of the bracket @@ -812,10 +812,9 @@ end; procedure TParamHint.ParamHintHide(Sender: TObject); begin - if FMP <> nil then - freeandnil(Fmp); + if Fmp <> nil then + FreeAndNil(Fmp); FDecl := nil; - FParameters:= nil; FSynEdit := nil; end; @@ -976,14 +975,19 @@ procedure TParamHint.Show(StartPoint,BracketPoint: TPoint;Decl : TciProcedureDec begin if self.Visible then self.hide; - FDecl := Decl; + Fmp := mp; FParameters:= Decl.GetParamDeclarations; if Length(FParameters) = 0 then //Method has no Parameters - exit; + begin + FreeAndNil(Fmp); + Exit; + end; + FDecl := Decl; FSynEdit := Editor; FStartPoint:= StartPoint; FBracketPoint:= BracketPoint; + CalculateBounds; //Calculate the size we need! self.Visible := true; end;