Talk:VirtualTreeview

From Lazarus wiki
Revision as of 12:56, 9 May 2005 by Vincent (talk | contribs)
Jump to navigationJump to search

The 4.0.17 package on sourceforge contains some memleaks. For one, I had to fix the lcl, see cvs-log.

Below is a patch for virtualtrees.pas.

--- D:\lazarus\projects\Virtualtrees-4.0.17\VirtualTrees.pas	Tue Apr 26 22:54:48 2005
+++ D:\lazarus\projects\Virtualtrees\VirtualTrees.pas	Mon May 09 11:04:46 2005
@@ -3840,7 +3840,6 @@
   try
     // Since we want the image list appearing in the correct system colors, we have to remap its colors.
     Images := TBitmap.Create;
-    OneImage := TBitmap.Create;
 //todo    if ColorRemapping then
 //      Images.Handle := CreateMappedRes(FindClassHInstance(TBaseVirtualTree), PChar(ImageName), Grays, SysGrays)
 //    else
@@ -3853,20 +3852,20 @@
       IL.Clear;
       IL.Height := Images.Height;
       IL.Width := Images.Height;
-      OneImage.Width := IL.Width;
-      OneImage.Height := IL.Height;
       MaskColor := clFuchsia;
 //later: bug in gtk    MaskColor := Images.Canvas.Pixels[0, 0]; // this is usually clFuchsia
       Dest := Rect(0, 0, IL.Width, IL.Height);
-       for I := 0 to (Images.Width div Images.Height) - 1 do
+      for I := 0 to (Images.Width div Images.Height) - 1 do
       begin
+        OneImage := TBitmap.Create;
+        OneImage.Width := IL.Width;
+        OneImage.Height := IL.Height;
         Source := Rect(I * IL.Width, 0, (I + 1) * IL.Width, IL.Height);
         OneImage.Canvas.CopyRect(Dest, Images.Canvas, Source);
         IL.AddMasked(OneImage, MaskColor);
       end;
     finally
       Images.Free;
-      OneImage.Free;
     end;
   finally
     Watcher.Leave;
@@ -3958,7 +3957,7 @@
   I, Width, Height: Integer;*)
 
 begin
-  // don't use system image set, since not very system has this.
+  // don't use system image set, since not every system has this.
   if Flat then
     IL := FlatImages
   else
@@ -4148,7 +4147,7 @@
 var
   HintWasEnabled: Boolean;
 
-begin exit;
+begin
 //mm  timeEndPeriod(MinimumTimerInterval);
 
   LightCheckImages.Free;
@@ -4158,8 +4157,10 @@
   FlatImages.Free;
   XPImages.Free;
   UtilityImages.Free;
+{$IFNDEF LCL} // System images are not used.
   SystemCheckImages.Free;
   SystemFlatCheckImages.Free;
+{$ENDIF}
 
 //x  if NeedToUnitialize then
 //x    OleUninitialize;
@@ -4198,7 +4199,7 @@
 
 procedure ReleaseThreadReference(Tree: TBaseVirtualTree);
 
-begin exit;
+begin
   if Assigned(WorkerThread) then
   begin
     Dec(WorkerThread.FRefCount);
@@ -4237,7 +4238,7 @@
 
 constructor TWorkerThread.Create(CreateSuspended: Boolean);
 
-begin exit;
+begin
   inherited Create(CreateSuspended);
   FChangeLock := TCriticalSection.Create;
   FWaiterList := TThreadList.Create;
@@ -4247,7 +4248,7 @@
 
 destructor TWorkerThread.Destroy;
 
-begin exit;
+begin
   FWaiterList.Free;
   FChangeLock.Free;
   inherited;
@@ -4375,7 +4376,7 @@
 
 procedure TWorkerThread.RemoveTree(Tree: TBaseVirtualTree);
 
-begin exit;
+begin
   Assert(Assigned(Tree), 'Tree must not be nil.');
 
   with FWaiterList.LockList do