Jump to content

M.Joos

Members
  • Content Count

    57
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by M.Joos


  1. 3 minutes ago, Dalija Prasnikar said:

    You can use RegEdit to remove registry key HKEY_CURRENT_USER\Software\Embarcadero\BDS\21.0

     

    Deleting (or renaming) that key will remove all custom settings.

     

    If possible it would be good to determine source of your problem. Do you have any IDE plugins installed in 10.3 or other 3rd party components - packages (including your own). Maybe imported settings are trying to load something incompatible. 

     

    I just tried to import my settings from 10.3 again in 10.4 and everything works fine for me.

    Thanks Dalija,

    indeed I have multiple IDE plugins installed. It is quite likely that these are the culprit. Maybe I should have a closer look at what exactly gets migrated and uncheck probably those that might be porblematic. And thanks for the trick of just deleting the registry key. I let you know how it turned out.


  2. I just ran the migration tool and wanted to transfer my settings from 10.3 to 10.4. Now at startup of 10.4 I get a "Index out of bounds error" with succesive "Interface not supported" errors. The Ide does not start any more. Does anybody have any ideas? Is there a way to undo the migration ?

    TIA

     


  3. 1 hour ago, Uwe Raabe said:

    Works as expected in Rio...

    You are right, Uwe. Tested it in 10.3.2 and it works as expected.

    Upon closer inspection it seems they fixed the Tinterlocked code which in Berlin looked like this:

    $ELSEIF Defined(X86ASM)}
    asm
      AND   EDX,31
      LOCK BTS   [EAX],EDX
      SETNC  AL
    end;
    {$ELSE}
    var

    and in Rio looks like this:

    {$ELSEIF Defined(X86ASM)}
    asm
      AND   EDX,31
      LOCK BTS   [EAX],EDX
      SETC  AL
    end;
    {$ELSE}

    Okay, and I thought I would be crazy or something


  4. Hi all, when running the following code

    program Project105;
    
    {$APPTYPE CONSOLE}
    
    {$R *.res}
    
    uses
      System.SysUtils, System.SyncObjs;
    var
      Sync: Integer;
      Test: Boolean;
    
    begin
      try
        TInterlocked.BitTestAndClear(Sync,0);
        Test := TInterlocked.BitTestAndSet(Sync,0);
        if Test then
          writeln('Why is Test true here ??') else
          writeln('Okay, That''s what I expected');
        readln;
      except
        on E: Exception do
          Writeln(E.ClassName, ': ', E.Message);
      end;
    end.

    Why is it that the variable Test is set to true, when the documentation says  ".... The method returns True if the bit is 1, False otherwise ". Clearly I have set the bit to 0 with TInterlocked.BitTestandClear, haven't I ? What am I missing.

    Tested with Delphi 10.1 Berlin.


  5. This is by design and not a specific problem of frames.

    So you cannot have platform specific design with frames.

    But maybe the approach suggested by Ray Konopka may work for you. He had given a session at Coderage 2018 called "Mobile View Management" in which he proposes an alternative to using frames.

    You can find the replay here: https://www.embarcaderoacademy.com/courses/441209/lectures/8426275

    (You need to sign up for free in order to be able to watch the replay)

     


  6. On 7/24/2019 at 12:27 AM, Uwe Raabe said:

    I can think of TFieldCache in System.Classes replacing several expensive calls to FieldAddress.

    I have not installed 10.3.2 yet, so don't have the source code to look at TfieldCache. But yes it makes a lot of sense to cache the Field addresses of a class, as in a typical form loading scenario you have multiple instances of the same class, so that the expensive code to determine the Field address is not repeated over and over again.

    Unfortunately  as Remy showed, this introduced some severe bugs, so I would expect a hot fix for 10.3.2 very soon. Hopefully they can fix TfieldCache rather than rolling back to the 10.3 approach for FieldAddress.


  7. 41 minutes ago, Sherlock said:

    Sorry, but I don't see a correlation between the result of a loop operation and its complexity. Consider this:

     

    
    var x: double;
    
    //x = 1000 maybe
    while (x > 1) do
         x := x + x;
         
    while (x > 1) do
         x := 2 * x;     

    Both loops will be O(n).

    No, in your example both loops will be O(INFINITE).

    Well, not quite. It would be O(MaxDouble / x) to be precise.

    • Haha 1

  8. 15 hours ago, Primož Gabrijelčič said:

    If one writes a unit test which tests the specification in full, it can in theory prove that a single-threaded unit complies with the specification.

    In theory, yes. But which unit tests can or do test the specification in full? Well, maybe some do, but e.g. the all so often used example of a unit test for an addition fails to test the full specification.

    • Like 1

  9. Be aware that there is a bug in the TMediaPlayer component that reports an "unsupported media file" error when it should have reported a "file not found" error. So first check if the file you are pointing to actually exists.

    • Like 1

  10. 7 minutes ago, Attila Kovacs said:

    Mhm,

    So avoid variables and everything should be ok in anon methods?

    Like that?

     

    
        case hType of
          foo:
            //Handler := TFoo.Create;
            Broker.AddHandler(TFoo.Create.OnHandle);
          bar:
            //Handler := TBar.Create;
            Broker.AddHandler(TBar.Create.OnHandle);
        end;

     

    Although I wouldn't phrase it like this, yes, this version should work. Variable capture is actually an important feature of anonymous methods. Without, they would hardly be more than a fancy way of procedural types.


  11. 16 hours ago, Attila Kovacs said:

    Thanks @mael and @M.Joos.

     

    This is actually very simple with the RegisterSelectionEditor.

    Here is the prototype I made, I don't really have any time to make it to a "product" nor to enhance it more.

     

    First you will need a simple wizard skeleton like http://www.tempest-sw.com/opentools/simple.html

     

    Then merge this code into it.

    Let me know if anything is missing.

     

    
    TCustomPropeFilter = class(TSelectionEditor, ISelectionpropertyFilter)
    private
      // I've no clue who is managing the instance so everything static
      class var FFilterPane: TPanel;
      class var FFilterBox: TButtonedEdit;
      class var FFilterCombo: TComboBox;
      class var FFilterList: TStringList;
      class var FPatternList: TStringList;
      class var FPropertyInspector: TForm;
      class var FOldPropertyInspectorActivate: TNotifyEvent;
      class procedure OnFilterComboCloseUp(Sender: TObject);
      class procedure RefreshSelection;
      class procedure OnFilterComboKeyPress(Sender: TObject; var Key: Char);
      class procedure OnPropertyInspectorActivate(Sender: TObject);
    protected
      { ISelectionPropertyFilter }
      procedure FilterProperties(const ASelection: IDesignerSelections; const ASelectionproperties: IInterfaceList);
    end;
    
    constructor TSimpleWizard.Create;
    begin
    
      // how to unregister?
      RegisterSelectionEditor(TControl, TCustomPropeFilter);
    
      TCustomPropeFilter.FPropertyInspector := TForm(Application.FindComponent('PropertyInspector'));
      if TCustomPropeFilter.FPropertyInspector <> nil then
      begin
        TCustomPropeFilter.FOldPropertyInspectorActivate := TCustomPropeFilter.FPropertyInspector.OnActivate;
        TCustomPropeFilter.FPropertyInspector.OnActivate := TCustomPropeFilter.OnPropertyInspectorActivate;
    
        TCustomPropeFilter.FFilterPane := TPanel(TCustomPropeFilter.FPropertyInspector.FindComponent('FilterPane'));
        if TCustomPropeFilter.FFilterPane <> nil then
        begin
          TCustomPropeFilter.FFilterBox := TButtonedEdit(TCustomPropeFilter.FPropertyInspector.FindComponent('FilterBox'));
    
          // I don't like the default search box. Do you?
          if TCustomPropeFilter.FFilterBox <> nil then
            TCustomPropeFilter.FFilterBox.Visible := False;
    
          TCustomPropeFilter.FFilterCombo := TComboBox.Create(TCustomPropeFilter.FFilterPane);
          TCustomPropeFilter.FFilterCombo.Name := 'FilterCombo';
          TCustomPropeFilter.FFilterCombo.Text := '';
          TCustomPropeFilter.FFilterCombo.Margins.Left := 0;
          TCustomPropeFilter.FFilterCombo.Margins.Top := 3;
          TCustomPropeFilter.FFilterCombo.Margins.Right := 0;
          TCustomPropeFilter.FFilterCombo.Margins.Bottom := 0;
          TCustomPropeFilter.FFilterCombo.AlignWithMargins := True;
          // TCustomPropeFilter.FFilterCombo.Top := 100; // needed only if default search-box is visible
          TCustomPropeFilter.FFilterCombo.Align := alTop;
          TCustomPropeFilter.FFilterPane.InsertControl(TCustomPropeFilter.FFilterCombo);
          TCustomPropeFilter.FFilterCombo.Items.Add('Pos & Size');
          TCustomPropeFilter.FFilterCombo.Items.Add('Display');
          TCustomPropeFilter.FFilterCombo.Items.Add('Name');
          TCustomPropeFilter.FFilterCombo.Items.Add('NewForm');
          TCustomPropeFilter.FFilterCombo.OnCloseUp := TCustomPropeFilter.OnFilterComboCloseUp;
          TCustomPropeFilter.FFilterCombo.OnKeyPress := TCustomPropeFilter.OnFilterComboKeyPress;
          TCustomPropeFilter.FFilterList := TStringList.Create;
          TCustomPropeFilter.FPatternList := TStringList.Create;
        end;
      end;
    end;
    
    { TCustomPropeFilter }
    
    class procedure TCustomPropeFilter.OnFilterComboCloseUp(Sender: TObject);
    begin
      RefreshSelection;
    end;
    
    class procedure TCustomPropeFilter.RefreshSelection;
    var
      AList: IDesignerSelections;
      Designer: IDesigner;
    begin
      Designer := ActiveRoot as IDesigner;
      if Designer = nil then
        Exit;
    
      AList := CreateSelectionList;
      Designer.GetSelections(AList);
    
      // If the selection contains only the current form. (No controls)
      if (AList.Count = 1) and (AList[0] = Designer.Root) then
        Designer.NoSelection
      else
        Designer.ClearSelection;
      Designer.SetSelections(AList);
    end;
    
    class procedure TCustomPropeFilter.OnFilterComboKeyPress(Sender: TObject; var Key: Char);
    begin
      case Key of
        #13:
          begin
            RefreshSelection;
            Key := #0;
          end;
        #27:
          begin
            if TCustomPropeFilter.FFilterCombo.Text <> '' then
            begin
              TCustomPropeFilter.FFilterCombo.ItemIndex := -1;
              TCustomPropeFilter.FFilterCombo.Text := '';
              RefreshSelection;
            end;
            Key := #0;
          end;
      end;
    end;
    
    class procedure TCustomPropeFilter.OnPropertyInspectorActivate(Sender: TObject);
    var
      CursorPos: TPoint;
      c: TControl;
    begin
      // This is insane but I've no better idea to avoid stealing the focus by Property Editor's OnActivate event
      GetCursorPos(CursorPos);
      c := FFilterPane.ControlAtPos(FFilterPane.ScreenToClient(CursorPos), True, True, True);
      if (c <> nil) and (c.Name = 'FilterCombo') then
        Exit;
    
      if Assigned(FOldPropertyInspectorActivate) then
        FOldPropertyInspectorActivate(Sender);
    end;
    
    procedure TCustomPropeFilter.FilterProperties(const ASelection: IDesignerSelections; const ASelectionproperties: IInterfaceList);
    var
      i, j: Integer;
      LSelectedItem: TPersistent;
      LProperty: IProperty;
      LPropertyName: String;
      MethodProperty: IMethodProperty;
    
      function PatternMatch(AList: TStringList; APropName: String): Boolean;
      var
        k: Integer;
      begin
        for k := 0 to AList.Count - 1 do
          if Pos(AList[k], APropName) > 0 then
            Exit(True);
        Result := False;
      end;
    
    begin
      if TCustomPropeFilter.FFilterCombo <> nil then
      begin
        // todo load the list from file or registry
        case TCustomPropeFilter.FFilterCombo.ItemIndex of
          - 1:
            begin
              if TCustomPropeFilter.FFilterCombo.Text <> '' then
              begin
                TCustomPropeFilter.FPatternList.Clear;
                TCustomPropeFilter.FFilterList.Text := StringReplace(TCustomPropeFilter.FFilterCombo.Text, ',', #13#10, [rfReplaceAll]);
                for i := TCustomPropeFilter.FFilterList.Count - 1 to 0 do
                  if Copy(TCustomPropeFilter.FFilterList[i], 1, 1) = '*' then
                  begin
                    TCustomPropeFilter.FPatternList.Add(Copy(TCustomPropeFilter.FFilterList[i].ToLower, 2));
                    TCustomPropeFilter.FFilterList.Delete(i);
                  end;
              end
              else
                Exit;
            end;
            
          // everything hardcoded because I'm a lazy dog  
          0:
            begin
              TCustomPropeFilter.FFilterList.Clear;
              TCustomPropeFilter.FFilterList.Add('Top');
              TCustomPropeFilter.FFilterList.Add('Left');
              TCustomPropeFilter.FFilterList.Add('Width');
              TCustomPropeFilter.FFilterList.Add('Height');
              TCustomPropeFilter.FFilterList.Add('ClientWidth');
              TCustomPropeFilter.FFilterList.Add('ClientHeight');
              TCustomPropeFilter.FFilterList.Add('TabOrder');
              TCustomPropeFilter.FFilterList.Add('Align');
              TCustomPropeFilter.FFilterList.Add('AlignWithMargins');
              TCustomPropeFilter.FFilterList.Add('Margins');
            end;
          1:
            begin
              TCustomPropeFilter.FFilterList.Clear;
              TCustomPropeFilter.FFilterList.Add('Caption');
              TCustomPropeFilter.FFilterList.Add('Text');
              TCustomPropeFilter.FFilterList.Add('Datasource');
              TCustomPropeFilter.FFilterList.Add('DataField');
            end;
          2:
            begin
              TCustomPropeFilter.FFilterList.Text := 'Name';
            end;
          3:
            begin
              TCustomPropeFilter.FFilterList.Clear;
              TCustomPropeFilter.FFilterList.Add('ActiveControl');
              TCustomPropeFilter.FFilterList.Add('BorderIcons');
              TCustomPropeFilter.FFilterList.Add('BorderStyle');
              TCustomPropeFilter.FFilterList.Add('Caption');
              TCustomPropeFilter.FFilterList.Add('ClientHeight');
              TCustomPropeFilter.FFilterList.Add('ClientWidth');
              TCustomPropeFilter.FFilterList.Add('Font');
              TCustomPropeFilter.FFilterList.Add('Name');
              TCustomPropeFilter.FFilterList.Add('Position');
            end;
        end;
    
        // todo implement pattern search like in the original IDE search box
        for i := 0 to ASelection.Count - 1 do
        begin
          LSelectedItem := ASelection[i];
          if (LSelectedItem is TControl) then
            for j := ASelectionproperties.Count - 1 downto 0 do
            begin
              if Supports(ASelectionproperties[j], IProperty, LProperty) then
                if not Supports(ASelectionproperties[j], IMethodProperty, MethodProperty) then
                begin
                  LPropertyName := LProperty.GetName;
                  if (TCustomPropeFilter.FFilterList.IndexOf(LPropertyName) = -1) and //
                    (not PatternMatch(TCustomPropeFilter.FPatternList, LPropertyName.ToLower)) then
                    ASelectionproperties.Delete(j);
                end;
            end;
        end;
      end;
    end;

     

    Thanks a lot.

    I will look and eventually extend your code somewhat. I am really missing the OI expert from Uwe Schuster, that went along similar ideas that you have. So maybe I can come up with a similar solution than Uwe's expert. At least your code is a good starting point, so thanks a lot for sharing.

    • Like 1

  12. 6 hours ago, Sherlock said:

    Oh, yes you are right. It is not built in. But it works with Rio! What I posted however is a screenshot with Tokyo.

    You can get the plugin here: https://github.com/MJSt/DelphiVersionInsight

    Compile it and activate the add-in DLL via a tool like GExperts Expert Manager. 

    Thanks a lot, works like a charm, also in RIO. Now if you would also have the "old" Object Inspector Expert from Uwe ..... that would be a dream !OI.png.89b15df2b358bef55791ff2f91322889.png

×