Sfoglia il codice sorgente

Merge pull request #38 from SkybuckFlying/GUIExperimentalBugFixes4

GUI Experimental Bug Fixes 4 (re-enables all functionality).
Herman Schoenfeld 4 anni fa
parent
commit
4fa2274ac4

+ 7 - 16
src/libraries/sphere10/UCommon.Collections.pas

@@ -343,12 +343,11 @@ begin
 end;
 
 class function TComparerTool<T>.Many(const comparers: array of IComparer<T>) : IComparer<T>;
-(*
 type
   __TArrayTool_IComparer_T = TArrayTool<__IComparer_T>;
-*)
+
 begin
-//  Result := TManyComparer<T>.Create( __TArrayTool_IComparer_T.Copy(comparers) ); // Skybuck: disabled for now
+  Result := TManyComparer<T>.Create( __TArrayTool_IComparer_T.Copy(comparers) ); // Skybuck: re-enabled
 end;
 
 class function TComparerTool<T>.Many(const comparers: TEnumerable<__IComparer_T>) : IComparer<T>;
@@ -365,10 +364,8 @@ begin
 end;
 
 class function TComparerTool<T>.AlwaysEqual : IComparer<T>;
-(*
 type
-  __TGlobalComparerFunc_T = TGlobalComparerFunc<T>;  // Skybuck: Disabled for now
-*)
+  __TGlobalComparerFunc_T = TGlobalComparerFunc<T>;  // Skybuck: Re-enabled
 begin
   Result :=  TComparerTool<T>.FromFunc( AlwaysEqualHandler );
 end;
@@ -469,10 +466,8 @@ begin
 end;
 
 class function TPredicateTool<T>.AndMany(const APredicates : array of IPredicate<T>) : IPredicate<T>;
-(*
-type
-  __TArrayTool_IPredicate_T = TArrayTool<__IPredicate_T>;  // Skybuck: Disabled for now
-*)
+// type
+//  __TArrayTool_IPredicate_T = TArrayTool<__IPredicate_T>;  // Skybuck: Disabled not needed
 var
   arr : TArray<__IPredicate_T>;
   i : Integer;
@@ -518,14 +513,10 @@ begin
 end;
 
 class function TPredicateTool<T>.OrMany(const APredicates : array of IPredicate<T>) : IPredicate<T>;
-// Skybuck: Disabled for now
-(*
 type
-  __TArrayTool_IPredicate_T = TArrayTool<__IPredicate_T>;
-*)
+  __TArrayTool_IPredicate_T = TArrayTool<__IPredicate_T>; // Skybuck: Re-enabled
 begin
-    // Skybuck: Disabled for now
-//  Result := TOrManyPredicate<T>.Create( __TArrayTool_IPredicate_T.Copy( APredicates) );
+  Result := TOrManyPredicate<T>.Create( __TArrayTool_IPredicate_T.Copy( APredicates) ); // Skybuck: Re-enabled
 end;
 
 class function TPredicateTool<T>.OrMany(const APredicates : array of TNestedPredicateFunc<T>) : IPredicate<T>;

+ 29 - 20
src/libraries/sphere10/UCommon.Data.pas

@@ -23,7 +23,7 @@ interface
 
 uses
   Classes, SysUtils, Generics.Collections, UMemory, UCommon, UCommon.Collections, Generics.Defaults,
-  Variants, LazUTF8, math, typinfo, syncobjs;
+  Variants, LazUTF8, math, typinfo, syncobjs, fgl;
 
 type
   TSortDirection = (sdNone, sdAscending, sdDescending);
@@ -234,8 +234,10 @@ const
   TDataSourceTool<T> = class
     protected type
       __IPredicate_T = IPredicate<T>;
-      __TList_IPredicate_T = TList<__IPredicate_T>;
+//      __TList_IPredicate_T = TList<__IPredicate_T>; // Skybuck: TList is buggy, disabled and replaced with TFPGList
+      __TList_IPredicate_T = TFPGlist<IPredicate<T>>;
     public
+     class function ArrayFromList( ParaList : __TList_IPredicate_T ) : TArray<IPredicate<T>>;
      class function ConstructRowComparer(const AFilters : TArray<TColumnFilter>; const ADelegate : TApplySortDelegate<T>) : IComparer<T>;
      class function ConstructRowPredicate(const AFilters : TArray<TColumnFilter>; const ADelegate : TApplyFilterDelegate<T>; const AOperand : TFilterOperand) : IPredicate<T>;
   end;
@@ -637,18 +639,15 @@ end;
 { TDataSourceTool }
 
 class function TDataSourceTool<T>.ConstructRowComparer(const AFilters : TArray<TColumnFilter>; const ADelegate : TApplySortDelegate<T>) : IComparer<T>;
-(*
 type
-  __IComparer_T = IComparer<T>; // Skybuck: Disabled for now
-*)
+  __IComparer_T = IComparer<T>; // Skybuck: Re-enabled
 var
   i : integer;
-//  comparers : TList<__IComparer_T>; // Skybuck: Disabled for now
+  comparers : TList<__IComparer_T>; // Skybuck: Re-enabled
   filter : TColumnFilter;
   GC : TDisposables;
 begin
-// Skybuck: Disabled for now
-(*
+// Skybuck: Re-enabled
   comparers := GC.AddObject(  TList<__IComparer_T>.Create ) as TList<__IComparer_T>;
   for i := Low(AFilters) to High(AFilters) do begin
     filter := AFilters[i];
@@ -661,42 +660,52 @@ begin
     1: Result := comparers[0];
     else Result := TComparerTool<T>.Many(comparers);
   end;
-*)
+end;
+
+// Skybuck: New temporarely ArrayFromList function until buggy TList is fixed by FPC compiler team (or generics team ?!?)
+class function TDataSourceTool<T>.ArrayFromList( ParaList : __TList_IPredicate_T ) : TArray<IPredicate<T>>;
+var
+  LIndex : integer;
+begin
+  // Skybuck: untested code, check and/or debug it !
+  SetLength( result, ParaList.Count );
+
+  for LIndex := 0 to length(result)-1 do
+  begin
+    result[LIndex] := ParaList.Items[LIndex];
+  end;
 end;
 
 class function TDataSourceTool<T>.ConstructRowPredicate(const AFilters : TArray<TColumnFilter>; const ADelegate : TApplyFilterDelegate<T>; const AOperand : TFilterOperand) : IPredicate<T>;
-// Skybuck: Disabled for now
-(*
+// Skybuck: Re-enabled
 type
   __TColumnFilterPredicate_T = TColumnFilterPredicate<T>;
   __TPredicateTool_T = TPredicateTool<T>;
-*)
 var
   i : integer;
   filters : __TList_IPredicate_T;
   GC : TDisposables;
 begin
-  // Skybuck: Disabled for now
-  (*
+  // Skybuck: Re-enabled
   filters := GC.AddObject( __TList_IPredicate_T.Create ) as __TList_IPredicate_T;
   for i := Low(AFilters) to High(AFilters) do begin
     if AFilters[i].Filter <> vgfSortable then begin
       filters.Add( __TColumnFilterPredicate_T.Create(AFilters[i], ADelegate));
     end;
   end;
-  *)
 
-  (*
-  // Skybuck: Free Pascal Compiler Bug/Internal Error 2015052501 (disabled for now).
+  // Skybuck: Free Pascal Compiler Bug/Internal Error 2015052501 caused by buggy TList, replaced with TFPGList.
   case filters.Count of
     0: Result := nil;
     1: Result := filters[0];
     else case AOperand of
-      foAnd: Result := __TPredicateTool_T.AndMany(filters.ToArray);
-      foOr: Result := __TPredicateTool_T.OrMany(filters.ToArray);
+//      foAnd: Result := __TPredicateTool_T.AndMany(filters.ToArray); // Skybuck: old TList bug
+//      foOr: Result := __TPredicateTool_T.OrMany(filters.ToArray); // Skybuck: old TList bug
+
+      foAnd: Result := __TPredicateTool_T.AndMany(ArrayFromList(filters)); // skybuck: new TFPGList fix
+      foOr: Result := __TPredicateTool_T.OrMany(ArrayFromList(filters));  // Skybuck: new TFPGList fix
     end;
   end;
-  *)
 end;
 
 { TPageFetchParams }

+ 1 - 1
src/libraries/sphere10/UWizard.pas

@@ -153,7 +153,7 @@ type
       function CancelRequested(out message : AnsiString) : boolean; override;
       function FinishRequested(out message : AnsiString) : boolean; override;
     public
-      constructor Create(AOwner:TComponent; title, finish: AnsiString; const screens : array of TComponentClass; cancelFunc: TActionWizardCancelFunc; finishFunc : TActionWizardFinishFunc); // Skybuck: disabled for now because of fpc compiler internal error: 200602034
+      constructor Create(AOwner:TComponent; title, finish: AnsiString; const screens : array of TComponentClass; cancelFunc: TActionWizardCancelFunc; finishFunc : TActionWizardFinishFunc);
       class procedure Show(AParent: TForm; title, finish: AnsiString; constref bag : T; const screens : array of TComponentClass; cancelFunc: TActionWizardCancelFunc; finishFunc : TActionWizardFinishFunc);
       property FinishText : AnsiString read FTitleText;
       property TitleText : AnsiString read FFinishText;