Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2002-12

Bugs and patch

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jeroen van Iddekinge

Hi,

I have found the following errors in lazarus:

propedits.pp/TPropertyEditor.PropDrawName
=================================
Untialised value:
Style.systemfont is not set.

GtkObject.inc/TGtkObject.Create
========================
Memory leak:
FGtkToolTips is first created with gtk_tooltips_new. After the tool tips are created, the functuon gtk_object_ref is called and the refcount is set
to 2. In TGtkObject.Destroy the recount of the tool tips is still 2. Because "unref" is
only called once the tool tips are not destroyed.

GtkObject.inc/GTKProc.SetStyle
========================
Memmory leak:
A Gtk-Tooltips group is created but never deleted.

Patch:

BaseCodeTools.pas/SearchCodeInSource
==============================
I rewrote this functies, and looks now cleaner and is faster. Attachment contains the patch for this (The errors mention above are NOT patched
with this file).
Hopefuly is usefull.

Saluti,

Jer

Only in /home/jeroen/source/laz2/lazarus/components/codetools: basiccodetools.bkp diff -ur components/codetools/basiccodetools.pas /home/jeroen/source/laz2/lazarus/components/codetools/basiccodetools.pas --- components/codetools/basiccodetools.pas Sat Nov 30 10:12:49 2002 +++ /home/jeroen/source/laz2/lazarus/components/codetools/basiccodetools.pas Sun Dec 22 17:11:20 2002 @@ -864,56 +864,67 @@

   Result:=true;

end;

+function ReadNextPascalAtomEx(const Source : string;var Position,EndPosition : integer;CaseSensitive : boolean; var Atom : string):boolean;
+begin
+     Atom := ReadNextPascalAtom(Source,Position,EndPosition);
+     if CaseSensitive then lowerCase(Atom);
+     Result := (Position > length(Source));
+end;
+
+// search pascal atoms of Find in Source
+
 function SearchCodeInSource(const Source,Find:string; StartPos:integer;
    var EndFoundPosition:integer;  CaseSensitive:boolean):integer;
-// search pascal atoms of Find in Source
-var FindAtomStart,FindPos,Position,AtomStart
-  ,FirstSrcAtomStart,FirstSrcAtomEnd:integer;
-  FindAtom,SrcAtom:string;
+var
+	FindAtomStart     : integer;
+	FindPos           : integer;
+	Position          : integer;
+	AtomStart         : integer;
+	FirstSrcAtomStart : integer;
+	CompareSrcPosition: integer;
+	FindAtom          : string ;
+	SrcAtom           : string;
+	HasFound          : boolean;
+	FirstFindAtom     : string;
+	FirstFindPos      : integer;
 begin
   Result:=-1;
   if (Find='') or (StartPos>length(Source)) then exit;
+
   Position:=StartPos;
+  FirstFindPos:=1;
+
+  {search first atom in find}
+
+  if ReadNextPascalAtomEx(Find,FirstFindPos,FindAtomStart,CaseSensitive,FirstFindAtom) then exit;
+
   repeat
-    // search first atom in find
-    FindPos:=1;
-    ReadNextPascalAtom(Find,FindPos,FindAtomStart);
-    FindAtom:=copy(Find,FindAtomStart,FindPos-FindAtomStart);
-    if FindAtom='' then exit;
-    if not CaseSensitive then FindAtom:=lowercase(FindAtom);
-    // search first atom in source
-    repeat
-      ReadNextPascalAtom(Source,Position,AtomStart);
-      SrcAtom:=copy(Source,AtomStart,Position-AtomStart);
-      if not CaseSensitive then SrcAtom:=lowercase(SrcAtom);
-    until (Position>length(Source)) or (SrcAtom=FindAtom);
-    if SrcAtom=FindAtom then begin
-      // first atom found
-      FirstSrcAtomStart:=AtomStart;
-      FirstSrcAtomEnd:=Position;
-      // compare the rest of Find
+
+     if ReadNextPascalAtomEx(Source,Position,AtomStart,CaseSensitive,SrcAtom) then break;
+
+     if SrcAtom=FirstFindAtom then begin
+      {first atom found}
+      FirstSrcAtomStart  := AtomStart;
+      CompareSrcPosition := Position;
+      FindPos := FirstFindPos;
+
+      {read next source and find atoms and compare}
+
       repeat
-        // get next atom in find
-        ReadNextPascalAtom(Find,FindPos,FindAtomStart);
-        FindAtom:=copy(Find,FindAtomStart,FindPos-FindAtomStart);
-        if FindAtom='' then break;
-        if not CaseSensitive then FindAtom:=lowercase(FindAtom);
-        // compare to next atom in source
-        ReadNextPascalAtom(Source,Position,AtomStart);
-        SrcAtom:=copy(Source,AtomStart,Position-AtomStart);
-        if not CaseSensitive then SrcAtom:=lowercase(SrcAtom);
-      until (SrcAtomFindAtom);
-      if (FindAtom='') and (FindAtomStart>length(Find)) then begin
-        // code found
-        Result:=FirstSrcAtomStart;
-        EndFoundPosition:=Position;
-        exit;
-      end;
-    end else begin
-      // first atom not found
-      exit;
-    end;
-    Position:=FirstSrcAtomEnd;
+
+        if ReadNextPascalAtomEx(Find,FindPos,FindAtomStart,CaseSensitive,FindAtom) then break;
+        if ReadNextPascalAtomEx(Source,CompareSrcPosition,AtomStart,CaseSensitive,SrcAtom) then break;
+
+        HasFound := SrcAtom = FindAtom;
+
+        if HasFound then begin
+           Result := FirstSrcAtomStart;
+           EndFoundPosition := CompareSrcPosition;
+           exit;
+        end;
+
+      until not(HasFound);
+     end;
   until false;
 end;

Reply by email

Jeroen van Iddekinge
to Jeroen van Iddekinge

Hi,

Sorry, In mine previous mail i did sent the wrong patch. Sending patch again...

Saluti
Jer

Jeroen van Iddekinge wrote 40 lines
Hi, I have found the following errors in lazarus: propedits.pp/TPropertyEditor.PropDrawName ================================= Untialised value: Style.systemfont is not set. GtkObject.inc/TGtkObject.Create ======================== Memory leak: FGtkToolTips is first created with gtk_tooltips_new. After the tool tips are created, the functuon gtk_object_ref is called and the refcount is set to 2. In TGtkObject.Destroy the recount of the tool tips is still 2. Because "unref" is only called once the tool tips are not destroyed. GtkObject.inc/GTKProc.SetStyle ======================== Memmory leak: A Gtk-Tooltips group is created but never deleted. Patch: BaseCodeTools.pas/SearchCodeInSource ============================== I rewrote this functies, and looks now cleaner and is faster. Attachment contains the patch for this (The errors mention above are NOT patched with this file). Hopefuly is usefull. Saluti, Jer

Only in /home/jeroen/source/laz2/lazarus/components/codetools: basiccodetools.bkp diff -ur components/codetools/basiccodetools.pas /home/jeroen/source/laz2/lazarus/components/codetools/basiccodetools.pas --- components/codetools/basiccodetools.pas Sat Nov 30 10:12:49 2002 +++ /home/jeroen/source/laz2/lazarus/components/codetools/basiccodetools.pas Sun Dec 22 18:33:18 2002 @@ -864,56 +864,67 @@

   Result:=true;

end;

+function ReadNextPascalAtomEx(const Source : string;var Position,EndPosition : integer;CaseSensitive : boolean; var Atom : string):boolean;
+begin
+     Atom := ReadNextPascalAtom(Source,Position,EndPosition);
+     if not(CaseSensitive) then Atom := lowerCase(Atom);
+     Result := (Position > length(Source));
+end;
+
+// search pascal atoms of Find in Source
+
 function SearchCodeInSource(const Source,Find:string; StartPos:integer;
    var EndFoundPosition:integer;  CaseSensitive:boolean):integer;
-// search pascal atoms of Find in Source
-var FindAtomStart,FindPos,Position,AtomStart
-  ,FirstSrcAtomStart,FirstSrcAtomEnd:integer;
-  FindAtom,SrcAtom:string;
+var
+	FindAtomStart     : integer;
+	FindPos           : integer;
+	Position          : integer;
+	AtomStart         : integer;
+	FirstSrcAtomStart : integer;
+	CompareSrcPosition: integer;
+	FindAtom          : string ;
+	SrcAtom           : string;
+	HasFound          : boolean;
+	FirstFindAtom     : string;
+	FirstFindPos      : integer;
 begin
   Result:=-1;
   if (Find='') or (StartPos>length(Source)) then exit;
+
   Position:=StartPos;
+  FirstFindPos:=1;
+
+  {search first atom in find}
+
+  if ReadNextPascalAtomEx(Find,FirstFindPos,FindAtomStart,CaseSensitive,FirstFindAtom) then exit;
+
   repeat
-    // search first atom in find
-    FindPos:=1;
-    ReadNextPascalAtom(Find,FindPos,FindAtomStart);
-    FindAtom:=copy(Find,FindAtomStart,FindPos-FindAtomStart);
-    if FindAtom='' then exit;
-    if not CaseSensitive then FindAtom:=lowercase(FindAtom);
-    // search first atom in source
-    repeat
-      ReadNextPascalAtom(Source,Position,AtomStart);
-      SrcAtom:=copy(Source,AtomStart,Position-AtomStart);
-      if not CaseSensitive then SrcAtom:=lowercase(SrcAtom);
-    until (Position>length(Source)) or (SrcAtom=FindAtom);
-    if SrcAtom=FindAtom then begin
-      // first atom found
-      FirstSrcAtomStart:=AtomStart;
-      FirstSrcAtomEnd:=Position;
-      // compare the rest of Find
+
+     if ReadNextPascalAtomEx(Source,Position,AtomStart,CaseSensitive,SrcAtom) then break;
+
+     if SrcAtom=FirstFindAtom then begin
+      {first atom found}
+      FirstSrcAtomStart  := AtomStart;
+      CompareSrcPosition := Position;
+      FindPos := FirstFindPos;
+
+      {read next source and find atoms and compare}
+
       repeat
-        // get next atom in find
-        ReadNextPascalAtom(Find,FindPos,FindAtomStart);
-        FindAtom:=copy(Find,FindAtomStart,FindPos-FindAtomStart);
-        if FindAtom='' then break;
-        if not CaseSensitive then FindAtom:=lowercase(FindAtom);
-        // compare to next atom in source
-        ReadNextPascalAtom(Source,Position,AtomStart);
-        SrcAtom:=copy(Source,AtomStart,Position-AtomStart);
-        if not CaseSensitive then SrcAtom:=lowercase(SrcAtom);
-      until (SrcAtomFindAtom);
-      if (FindAtom='') and (FindAtomStart>length(Find)) then begin
-        // code found
-        Result:=FirstSrcAtomStart;
-        EndFoundPosition:=Position;
-        exit;
-      end;
-    end else begin
-      // first atom not found
-      exit;
-    end;
-    Position:=FirstSrcAtomEnd;
+
+        if ReadNextPascalAtomEx(Find,FindPos,FindAtomStart,CaseSensitive,FindAtom) then break;
+        if ReadNextPascalAtomEx(Source,CompareSrcPosition,AtomStart,CaseSensitive,SrcAtom) then break;
+
+        HasFound := SrcAtom = FindAtom;
+
+        if HasFound then begin
+           Result := FirstSrcAtomStart;
+           EndFoundPosition := CompareSrcPosition;
+           exit;
+        end;
+
+      until not(HasFound);
+     end;
   until false;
 end;

Reply by email

Mattias Gaertner
to Jeroen van Iddekinge: I have found the following errors in lazarus: propedits.pp/TPropertyEditor.PropDrawName…
Show quoted text 8 lines
Hi, I have found the following errors in lazarus: propedits.pp/TPropertyEditor.PropDrawName ================================= Untialised value: Style.systemfont is not set.

Fixed

Show quoted text 9 lines
GtkObject.inc/TGtkObject.Create ======================== Memory leak: FGtkToolTips is first created with gtk_tooltips_new. After the tool tips are created, the functuon gtk_object_ref is called and the refcount is set to 2. In TGtkObject.Destroy the recount of the tool tips is still 2. Because "unref" is only called once the tool tips are not destroyed.

Fixed.

GtkObject.inc/GTKProc.SetStyle ======================== Memmory leak: A Gtk-Tooltips group is created but never deleted.

SetStyle?
Do you mean GetStyle?

Show quoted text 5 lines
Patch: BaseCodeTools.pas/SearchCodeInSource ============================== I rewrote this functies, and looks now cleaner and is faster.

Applied.
FYI: This function is not used by the IDE.

Attachment contains the patch for this (The errors mention above are NOT patched with this file). Hopefuly is usefull.

:)

Mattias

Reply by email

Jeroen van Iddekinge

Mattias,

Mattias Gaertner wrote 10 lines
On Sun, 22 Dec 2002 17:47:24 +0100 Jeroen van Iddekinge wrote: > GtkObject.inc/GTKProc.SetStyle > ======================== > Memmory leak: > A Gtk-Tooltips group is created but never deleted. SetStyle? Do you mean GetStyle?

Eeeuh sorry, Yes

Show quoted text 9 lines
> Patch: > > BaseCodeTools.pas/SearchCodeInSource > ============================== > I rewrote this functies, and looks now cleaner and is faster. Applied. FYI: This function is not used by the IDE.

Whatever, thanx

Saluti,
Jer

Reply by email