Ignore:
Timestamp:
Mar 18, 2022, 3:47:27 PM (3 years ago)
Author:
chronos
Message:
  • Modified: Code cleanup.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/CoolWeb/WebServer/UWebApp.pas

    r108 r132  
    66
    77uses
    8   Classes, SysUtils, CustApp, SpecializedList, UWebPage, UHTTPSessionFile,
    9   UHTTPServer, Forms, FileUtil;
     8  Classes, SysUtils, UWebPage, UHTTPSessionFile,
     9  UHTTPServer, Forms, FileUtil, fgl;
    1010
    1111type
     
    2222  { TPageList }
    2323
    24   TPageList = class(TListObject)
     24  TPageList = class(TFPGObjectList<TRegistredPage>)
    2525    RootDir: string;
    2626    function FindByPage(Page: TWebPage): TRegistredPage;
     
    2929    procedure UnregisterPage(Page: TWebPage);
    3030    function ProducePage(HandlerData: THTTPHandlerData): Boolean;
    31     constructor Create; override;
     31    constructor Create(FreeObjects: Boolean = True);
    3232  end;
    3333
     
    6464  UHTTPServerCGI, UHTTPServerTCP, UHTTPServerTurboPower;
    6565
    66 
    6766procedure Register;
    6867begin
     
    7776end;
    7877
    79 
    8078{ TPageList }
    8179
     
    8583begin
    8684  I := 0;
    87   while (I < Count) and (TRegistredPage(Items[I]).Page <> Page) do Inc(I);
    88   if I < Count then Result := TRegistredPage(Items[I])
     85  while (I < Count) and (Items[I].Page <> Page) do Inc(I);
     86  if I < Count then Result := Items[I]
    8987    else Result := nil;
    9088end;
     
    9593begin
    9694  I := 0;
    97   while (I < Count) and (TRegistredPage(Items[I]).Name <> Name) do Inc(I);
    98   if I < Count then Result := TRegistredPage(Items[I])
     95  while (I < Count) and (Items[I].Name <> Name) do Inc(I);
     96  if I < Count then Result := Items[I]
    9997    else Result := nil;
    10098end;
     
    132130var
    133131  NewPage: TRegistredPage;
    134   Instance: TWebPage;
    135 begin
    136   NewPage := TRegistredPage(AddNew(TRegistredPage.Create));
     132begin
     133  NewPage := TRegistredPage.Create;
    137134//  NewPage.Page := PageClass.Create(Self);
    138135  NewPage.Page := Page;
    139136  NewPage.Name := Path;
     137  Add(NewPage);
    140138end;
    141139
     
    166164constructor TPageList.Create;
    167165begin
    168   inherited Create;
    169   OwnsObjects := False;
     166  inherited;
     167  FreeObjects := False;
    170168end;
    171169
     
    212210constructor TWebApp.Create(AOwner: TComponent);
    213211begin
    214   inherited Create(AOwner);
     212  inherited;
    215213  HTTPServer := THTTPServerCGI.Create(nil);
    216214  HTTPServer.OnRequest := HTTPServerRequest;
     
    219217destructor TWebApp.Destroy;
    220218begin
    221   HTTPServer.Free;
    222   inherited Destroy;
     219  FreeAndNil(HTTPServer);
     220  inherited;
    223221end;
    224222
Note: See TracChangeset for help on using the changeset viewer.