-
Content Count
1291 -
Joined
-
Last visited
-
Days Won
28
Posts posted by Sherlock
-
-
12 minutes ago, Rollo62 said:That shows the core differences in the different languages:
C++ = pointer love
Delphi = pointer hateBut why: pointers are always, and will be always out there, till the end of days (at least when it comes to the bare metal).
I don't hate them, I just don't need them. 😉
-
1
-
1
-
-
I have gone through the code and replaced those pesky FreeAndNils with FreeMem or Dispose, whatever fit. It compiles fine now, but next step is to redesign the code to get rid of those ancient pointer thingies altogether. Quite annoying.
Thanks everyone for your help and insight!
-
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.
-
@Dalija Prasnikar Thank you! I thought that might be the reason. Which brings me to my earlier question: Why use FreeAndNil on Pointers in the first place? Do you have any idea?
-
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 🤣
-
German is OK as well
I would always use indexed format specifiers though.
-
1
-
-
Sorry, didn't catch the subform. Can't help then.
-
1
-
-
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.
-
-
Of course you might exclude existing users. Those with 32Bit iOS. How many are there, though? What do you know about your users? Do you have any information?
However, that still wont lead to a new AppID.
-
-
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.
-
3
-
-
Thanks for the heads up. Did you report it at QP?
-
Some files are in use while Delphi is running, so they can't be deleted. I am not sure there is any mechanism that can bypass this. Another subject for Embarcadero to look into.
-
Now that is a swift and elegant recovery from the blunder earlier. Respect @Embarcadero.
-
It's called consistency and is considered to be a good thing...most of the time.
-
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.
-
1
-
-
@mvanrijnen That's the reason, yes. But! It should be possible to have a "Restart IDE after install" checkbox, and to be able to uncheck it, when you want to install several things, to then restart after all that, shortening the overall install time significantly.
-
2
-
-
1 hour ago, Uwe Raabe said:<irony>Indeed! Why just didn't they defer the 10.4 release until yesterday when KSVC was ready. That would have made everyone happy, wouldn't it?</irony>
TBH... that may really have been true. Some more bugs could have been fixed as well in that time. But, same is true if they had deferred the release until next year... so, all is good, the way it happened.
-
I feared this could happen. It's the same as 10.2 -> 10.3. GetIt does not seem to care about parallel installations and overwrites the "old" Parnassus files.
-
That's what I would do as well. Though it is nice to have everything in one unit...it is not nice to do so, because that code is not reusable, especially if it is in a dpr. And you never know, if you'll need it later on.
-
1
-
-
That link needed some correcting, only got 404 from it. So...what is this? A Chatbot for WhatsApp? What do the boys and girls in FB-Land think of it? Is that a violation of some ToS?
-
Did my civic duty and helped push the server out of the mud.* Then voted for the issue.
* Not really
-
How to increase the distance between TCheckBox glyph and caption text?
in VCL
Posted
That will fail quickly for word wrapped captions.