Jump to content

Sherlock

Moderators
  • Content Count

    1209
  • Joined

  • Last visited

  • Days Won

    25

Posts posted by Sherlock


  1. 9 hours ago, Remy Lebeau said:

    I really wish Delphi would stop mimicking DotNet.  Delphi IS NOT DotNet!

    Aye, there's the rub.

    I propose exchanging DotNet with <SomeLanguage>. But folks keep saying "I want <SomeLanguage> feature x, because that is so cool, and I simply can't write my application without it". And then we get some half cooked thing which resembles <SomeLanguage> feature x by intent, but is buggy and breaks other stuff...


  2. 12 minutes ago, Rollo62 said:

    Don't mess with youself too much,
    if Microsoft shows not any attempt to make these controls practically more usable since the last 20+ years, why should we do ?

     

    I must really say that meanwhile I hate to fix all the quirks in OS, IDE, tools, libraries, etc.
    Enough to do with my own, selfmade errors :classic_blush:

     

    And in the end, what is the effort worth? Just to say: "In my product 1+1 is still 2 but it looks better than the others".


  3. 8 minutes ago, Uwe Raabe said:

    Either someone didn't understand FreeAndNil or the code used TObject in the first place and later changed to a typed pointer, but forgot to adjust the FreeAndNil call.

    You could think that to be the reason, but I'm looking at code with tons of PArrayOfByte like what I posted. This seems like some very, very old code and an array of byte is rarely implemented as a class is it? Much less back in the olden days.


  4. So I've been digging into some component codes just for the heck of it, and stumbled across a whole lot of code like the following snippet:

    procedure Foo;
    var
      Bar: PArrayOfByte;
    begin
      // Do some more or less elaborate thing with Bar
      // and in the end
      FreeAndNil(Bar);
    end;

    Now, first off, that is not how I had understood FreeAndNil. I always thought it to be usable for object instances. Of course one could argue, that whatever is behind a pointer could be an object itself, but I mean some thingy that was created via a TObject.Create. And sure enough, Delphi 10.4 will no longer compile stunts like these. It will give an E2010 and bluntly state that TObject and PArrayOfByte are not compatible. And rightly so.

     

    So...What to do? How to fix? Given that (in the above crude example) Bar must have been allocated memory via System.GetMem or System.New, System.FreeMem or Sysem.Dispose will do the trick, right?

    Why was this not done in the first place, though? Why mix paradigms at the risk of creating some unholy entity mucking up the entire system?

    Perhaps looking into FreeAndNil will enlighten us?

    This is 10.3.1s take on that method:

    procedure FreeAndNil(var Obj);
    {$IF not Defined(AUTOREFCOUNT)}
    var
      Temp: TObject;
    begin
      Temp := TObject(Obj);
      Pointer(Obj) := nil;
      Temp.Free;
    end;
    {$ELSE}
    begin
      TObject(Obj) := nil;
    end;
    {$ENDIF}

    And here is what 10.4 considers to be correct:

    procedure FreeAndNil(const [ref] Obj: TObject);
    {$IF not Defined(AUTOREFCOUNT)}
    var
      Temp: TObject;
    begin
      Temp := Obj;
      TObject(Pointer(@Obj)^) := nil;
      Temp.Free;
    end;
    {$ELSE}
    begin
      Obj := nil;
    end;
    {$ENDIF}

    Subtle, innit? Now FreeAndNil requires the thing it's supposed to free and nil to be of TObject, which is cool. But it also considers it to be const...why is that? I learned const renders the parameter unmodifiable, see here: http://docwiki.embarcadero.com/RADStudio/Rio/en/Parameters_(Delphi)#Constant_Parameters. I also took a wrong turn somewhere and ended up in this C++ explantion of const http://docwiki.embarcadero.com/RADStudio/Rio/en/Const in detail this sentence: "A const pointer cannot be modified, though the object to which it points can be changed." OK, so we can change the object, we are freeing it after all. But then we also change where the pointer points to, by niling it. Now that should violate the const boundary, but it does not. Is it because of the "fancy shmancy" use of @s and ^s here?

    TObject(Pointer(@Obj)^) := nil;

    Why? Why go to the lenghts of casting, adressing and dereferencing?

    What are your thoughts and comments on this?

     

    I think this almost cured my urge to look into the sources of other people 🤣


  5. We are not aware of the complete wording of said offer, that is something between Andreas and Embarcadero. What we do know from past statements however, is that some form of NDA or other contracts might be involved. But lets not speculate. IDEFixPAck will come once Andreas gets to install a 10.4 CE, which will come out with 10.4.1. So keep your fingers crossed, that this well be soon enough.


  6. On 6/19/2020 at 4:21 PM, Bernard said:

    I have a customer base that run windows 7 PCs with machine control software on them.  These machines require periodic software updates.  Some of these guys who have the machines are not technical at all.  They know how to turn machuines on and off and use the machine software.  Some of them have no internet so updates are sent on USB.  That is why Win 7 support is a requirement.

    I totally understand, but some eye candy just wont work. And sooner or later some other stuff will follow.

    This discussion is as old as Windows itself. It used to be "my customers only run DOS" then became "my customers only run 16Bit Windows" over to "my customers only run WinXP"  to what we have today. Someone in that story has not learned, and should be beaten with a set of Windows installation floppies: Hardware manufacturers that create one version of their controlling software and never update it, or for an ungodly price. We could break our ears and keep our software running on DOS, or just inform the customers and let them wise up and do a pitchfork and torch run on their machine manufacturer. After all, it is your hide they'll be after if something wont work because their system is outdated - not that this is the case right now.

    • Like 3

  7. On 6/16/2020 at 8:07 PM, Bernard said:

    Hi All,

     

    Just got a  chance to install Delphi 10.4 on my windows 7 Laptop and loaded up a sample.

    I ran it and when I change the VCL style to Windows10Blue or Windows10Dark it displays incorrectly

     

    Anyone else got this.

     

    By the way thanks everyone for the great info on this site

    Windows 7 is no longer supported, nor should it be. Why support anything even the original manufacturer only supports grudgingly and for a price? As a consequence applications will run, but eye candy will not be as sweet as intended. That seems to be a good compromise to me.

    • Like 1
×