Browse Source

* More fixes, remove lazutils dependency

Michaël Van Canneyt 1 year ago
parent
commit
6001409fb8
2 changed files with 8 additions and 67 deletions
  1. 8 64
      src/fresnel.app.pas
  2. 0 3
      src/fresnel.lpk

+ 8 - 64
src/fresnel.app.pas

@@ -5,8 +5,7 @@ unit Fresnel.App;
 interface
 
 uses
-  Classes, SysUtils, CustApp, Fresnel.Events, Fresnel.Forms, Fresnel.WidgetSet,
-  LazMethodList, LazLoggerBase;
+  Classes, SysUtils, CustApp, Fresnel.Events, Fresnel.Forms, Fresnel.WidgetSet;
 
 type
   TApplicationFlag = (
@@ -33,7 +32,6 @@ type
     FOldExceptProc: TExceptProc;
     procedure Activate(Data: Pointer);
     procedure Deactivate(Data: Pointer);
-    procedure QueuedReleaseComponents(Data: Pointer);
   protected
   protected
     FFlags: TApplicationFlags;
@@ -52,7 +50,7 @@ type
     procedure ReleaseComponent(aComponent : TComponent);
 
     procedure ProcessAsyncCallQueue; virtual;
-    procedure ReleaseComponents; virtual;
+
     procedure SetCaptureExceptions(const AValue: Boolean); virtual;
     procedure SetFlags(const AValue: TApplicationFlags); virtual;
   public
@@ -80,6 +78,8 @@ var
 
 implementation
 
+uses fresnel.classes;
+
 var
   HandlingException: Boolean = False;
   HaltingProgram: Boolean = False;
@@ -87,7 +87,7 @@ var
 procedure ExceptionOccurred(Sender: TObject; Addr: Pointer; FrameCount: Longint;
   Frames: PPointer);
 Begin
-  DebugLn('[Fresnel.Forms] ExceptionOccurred ');
+  FLLog(etDebug,'[Fresnel.Forms] ExceptionOccurred ');
   if HaltingProgram or HandlingException then Halt;
   if Addr=nil then ;
   if FrameCount=0 then ;
@@ -96,14 +96,9 @@ Begin
   HandlingException:=true;
   if Sender<>nil then
   begin
-    DebugLn('  Sender=',Sender.ClassName);
-    if Sender is Exception then
-    begin
-      DebugLn('  Exception=',Exception(Sender).Message);
-      DumpExceptionBackTrace();
-    end;
+    FLLog(etDebug,'  Sender='+Sender.Tostring);
   end else
-    DebugLn('  Sender=nil');
+      FLLog(etDebug,'  Sender=nil');
   if FresnelApplication<>nil then
     FresnelApplication.HandleException(Sender);
   HandlingException:=false;
@@ -186,11 +181,6 @@ begin
   if Data=nil then ;
 end;
 
-procedure TFresnelApplication.QueuedReleaseComponents(Data: Pointer);
-begin
-  if Data=nil then ;
-  ReleaseComponents;
-end;
 
 procedure TFresnelApplication.DoBeforeFinalization;
 var
@@ -225,52 +215,6 @@ begin
   DoHandleAsyncCalls;
 end;
 
-procedure TFresnelApplication.ReleaseComponents;
-var
-  Component: TComponent;
-  IsReferenced: Boolean;
-begin
-  if FComponentsReleasing<>nil then exit; // currently releasing
-  if (FComponentsToRelease<>nil) then begin
-    if FComponentsToRelease.Count=0 then begin
-      FreeAndNil(FComponentsToRelease);
-      exit;
-    end;
-    // free components
-    // Notes:
-    //   - check TLCLComponent.LCLRefCount=0
-    //   - during freeing new components can be added to the FComponentsToRelease
-    //   - components can be removed from FComponentsToRelease and FComponentsReleasing
-    FComponentsReleasing:=FComponentsToRelease;
-    FComponentsToRelease:=nil;
-    try
-      while (FComponentsReleasing<>nil) and (FComponentsReleasing.Count>0) do
-      begin
-        Component:=TComponent(FComponentsReleasing[0]);
-        FComponentsReleasing.Delete(0);
-        IsReferenced:=false; // (Component is TFresnelElement) and (TFresnelElement(Component).RefCount>0);
-        if IsReferenced then
-        begin
-          // add again to FComponentsToRelease
-           ReleaseComponent(Component);
-        end else begin
-          // this might free some more components from FComponentsReleasing
-          Component.Free;
-        end;
-      end;
-    finally
-      // add remaining to FComponentsToRelease
-      while (FComponentsReleasing<>nil) and (FComponentsReleasing.Count>0) do
-      begin
-        Component:=TComponent(FComponentsReleasing[0]);
-        FComponentsReleasing.Delete(0);
-        ReleaseComponent(Component);
-      end;
-      FreeAndNil(FComponentsReleasing);
-    end;
-  end;
-end;
-
 constructor TFresnelApplication.Create(AOwner: TComponent);
 begin
   inherited Create(AOwner);
@@ -444,7 +388,7 @@ procedure TFresnelApplication.Idle(Wait: Boolean);
 var
   Done: Boolean;
 begin
-  ReleaseComponents;
+
   ProcessAsyncCallQueue;
 
   Done := True;

+ 0 - 3
src/fresnel.lpk

@@ -112,9 +112,6 @@ The skia backend requires the sk4d library, e.g. sk4d.dll for Windows. A version
       </Item>
     </Files>
     <RequiredPkgs>
-      <Item>
-        <PackageName Value="LazUtils"/>
-      </Item>
       <Item>
         <PackageName Value="FresnelBase"/>
         <DefaultFilename Value="base/fresnelbase.lpk" Prefer="True"/>