1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-12-23 07:48:50 -05:00

Fixed (possible) memory leak in param hints.

Fixed an error that I got at closing.
Fixed param hints for anonymous functions (var a: procedure(b: Integer) and OnChange for example).
This commit is contained in:
Niels 2010-05-24 00:06:56 +02:00
parent c29d3b66e4
commit f7aa6ddc93
3 changed files with 54 additions and 37 deletions

View File

@ -16,7 +16,7 @@ type
function RegCreateKeyEx(
Key: LongWord; lpSubKey: TCharArray{PChar}; Reserved: LongInt; lpClass: Integer;
dwOptions: LongInt; samDesired: LongWord; SecurityAttributes: Integer;
var pResult: LongWord; dwDisposition: TIntegerArray{PInteger}
var pResult: LongWord; var dwDisposition: Integer
): LongInt; external 'RegCreateKeyExA@advapi32.dll stdcall';
function RegCloseKeyEx(
@ -107,11 +107,10 @@ end;
function RegOpenKey(KeyName: string; Root: LongWord; out Key: LongWord): Boolean;
var
s: TCharArray;
disp: TIntegerArray;
disp: Integer;
begin
Result := False;
s := StringToCharArray(KeyName); //Conversion to "PChar"
SetLength(disp, 1);
case RegCreateKeyEx(Root, s, 0, 0, REG_OPTION_NON_VOLATILE, KEY_WRITE, 0, Key, disp) of
ERROR_SUCCESS: Result := True;
ERROR_ACCESS_DENIED: WriteLn('Access denied');
@ -122,7 +121,7 @@ begin
ERROR_KEY_DELETED: WriteLn('Key marked for deletion');
end;
case disp[0] of
case disp of
1: WriteLn('Key "'+KeyName+'" did not exist and was created.');
2: WriteLn('Key "'+KeyName+'" existed and was simply opened without being changed.');
end;

View File

@ -1794,7 +1794,7 @@ end;
}
procedure TSimbaForm.doOnHide(Sender: TObject);
begin
if DebugImgForm.Visible then
if (not (csDestroying in ComponentState)) and (DebugImgForm <> nil) and DebugImgForm.Showing then
DebugImgForm.Hide;
end;

View File

@ -582,6 +582,8 @@ var
i : integer;
begin;
result := '';
if (Strings = nil) then
exit;
if endpos.y < beginpos.y then
exit;
if endpos.y >= strings.Count then
@ -612,10 +614,13 @@ var
CursorXY : TPoint;
begin
result := -1;
if (FSynEdit = nil) or (FParameters = nil) then
Exit;
MustHide := True;
Parser := TmwPasLex.Create; //The position of the bracket
parser.Origin:= PChar(StringListPartToText(Point(FBracketPoint.x,FBracketPoint.y-1),
point(min(FSynEdit.CaretX,length(FSynEdit.Lines[FSynEdit.CaretY - 1])+1),FSynEdit.CaretY-1),
try
Parser.Origin:= PChar(StringListPartToText(Point(FBracketPoint.x,FBracketPoint.y-1),
Point(min(FSynEdit.CaretX,length(FSynEdit.Lines[FSynEdit.CaretY - 1])+1),FSynEdit.CaretY-1),
FSynEdit.lines));
bracketcount := 0;
ParameterIndex := -1;
@ -642,6 +647,9 @@ begin
end;
parser.NextNoJunk;
end;
finally
Parser.Free;
end;
if parameterindex = -1 then
exit;
if parameterindex = LastParameterIndex then
@ -653,11 +661,11 @@ begin
end;
str := '';
ParamC := 0;
typedecl := FDecl.Name;
{typedecl := FDecl.Name;
if typedecl = nil then
exit;
if typedecl.shorttext = '' then
exit;
exit;}
for i := 0 to high(FParameters) do
begin
if (FParameters[i] is TciConstParameter) then
@ -703,17 +711,22 @@ begin
else
str := s + params + typestr;
end;
TypeDecl := FDecl.Items.GetFirstItemOfClass(TciReturnType);
if (FDecl <> nil) then
TypeDecl := FDecl.Items.GetFirstItemOfClass(TciReturnType)
else
TypeDecl := nil;
if TypeDecl <> nil then
TypeStr := ': ' + typedecl.ShortText
else
TypeStr := '';
str := FDecl.Name.ShortText + '(' + str + ')' + TypeStr + ';';
str := '(' + str + ')' + TypeStr + ';';
if (FDecl <> nil) and (FDecl.Name <> nil) then
str := FDecl.Name.ShortText + str;
str := StringReplace(str,'\\','',[rfReplaceAll]); //Delete all the \\, something like \const \\x\ is the same as \const x\
MustHide := False;
Result := parameterindex;
fPreparedString := str;
Parser.Free;
end;
destructor TParamHint.Destroy;
@ -742,6 +755,8 @@ var
ClientXY: TPoint;
ScreenXY: TPoint;
begin
if (FSynEdit = nil) then
Exit;
ScreenTextXY := FSynEdit.LogicalToPhysicalPos(FStartPoint);
ClientXY := FSynEdit.RowColumnToPixels(ScreenTextXY);
DrawWidth := FSynEdit.ClientWidth; //Maximum width it can have..
@ -799,6 +814,9 @@ procedure TParamHint.ParamHintHide(Sender: TObject);
begin
if FMP <> nil then
freeandnil(Fmp);
FDecl := nil;
FParameters:= nil;
FSynEdit := nil;
end;
procedure TParamHint.DrawHints(var MaxWidth, MaxHeight: Integer;