Jump to content

David Heffernan

Members
  • Content Count

    3586
  • Joined

  • Last visited

  • Days Won

    176

Everything posted by David Heffernan

  1. David Heffernan

    Enhanced messageboxes

    I have my own functions that call the task dialog api rather than using the VCL component.
  2. David Heffernan

    Enhanced messageboxes

    You don't need a component on a form
  3. David Heffernan

    Enhanced messageboxes

    Isn't this a VCL styles bug? Won't happen with plain windows theme.
  4. David Heffernan

    A book about Object Pascal Style Guide

    Why don't you let us give you extra sets of eyes?
  5. David Heffernan

    A book about Object Pascal Style Guide

    Perhaps I misunderstood the point you were trying to make, but that pattern of returning a newly created instance, with a Free in the except block is useful. Even then the FreeAndNil isn't needed because Result is not seen by the caller.
  6. David Heffernan

    A book about Object Pascal Style Guide

    Not really. The call to LoadFromStream could fail.
  7. David Heffernan

    A book about Object Pascal Style Guide

    Yes there is. I explained what was wrong in my first comment. The try of the try/finally is before the local variable LTextFile is assigned, but it should be immediately after it.
  8. David Heffernan

    A book about Object Pascal Style Guide

    I don't think the issue is complexity, the example is fine. it's just a couple of minor inaccuracies. That said, I'd strip out the FileExists check and just focus on the exception handling: LTextFile := TStringStream.Create; try LTextFile.LoadFromFile(AFileName); Result := TMemoryStream.Create; try Result.LoadFromStream(LTextFile); except FreeAndNil(Result); raise; end; finally LTextFile.Free; end; If you'd like people to comment on the entire book, do ask!
  9. David Heffernan

    A book about Object Pascal Style Guide

    This looks very interesting. After a quick skim of one topic on I note that there's an error on page 89 that is worth addressing. LTextFile is protected by a try/finally but created after the try rather than before the try. In that example I'd also put the try of the try/except immediately after the assignment to Result rather than two lines before it. For what it is worth I'm sure that if you had posted here then quote a few people would have read your book and looked for errors and given feedback. I would happily have done so and would still do so.
  10. vtune with map2pdb is excellent. It will take time to set it up, but it will save you time in the long run. And you'll have a better end result.
  11. Yes. Use a buffered line reader. But more importantly measure where your code spends its time. Don't guess.
  12. David Heffernan

    Showing a warning form to some users

    Sounds like you need to build some messaging infrastructure in to your program.
  13. Regarding the code in the previous post, every call to Delete performs both a copy and a heap allocation. You should be able to do this with one heap allocation and one copy.
  14. David Heffernan

    Using translations in unit Consts with Delphi 10.4 VCL

    Why isn't the function call mapping to the native TaskDialog and so letting the OS provide the captions?
  15. No. There is no problem. If there are multiple threads then the OS will schedule them into different logic processor cores. Always has. You misdiagnosed your problem before.
  16. The entire point of a threads are to allow code to execute in parallel in the same process.
  17. David Heffernan

    progress bar issue

    Make a minimal example that we can run. Or just debug your code.
  18. Yes, through context switches the OS preserves the CPU and FPU state which is part of the thread context
  19. I set the floating point control state to the Windows default (which masks exceptions) before calling any external library, and then restore it when those calls return. In order for this to work reliably in a multi-threaded environment you need to do some serious RTL patching to fix the thread safety issues. No, it is possible to fix the RTL so that you don't require such an invasive solution as you imagine. My numerical software does this. Many years ago I submitted a QC report with the attached document which explains how to fix it. Embarcadero have done nothing yet, although deleting QC meant that my report disappeared from public view! Rethinking Delphi Floating Point Control Register Management.pdf
  20. David Heffernan

    Using uninitialized object works on Win32, throws AV on Win64

    Sure. But there are plenty of methods where you can make changes. Just because something doesn't solve all problems, doesn't mean that solving some problems isn't possible or useful. But for sure in an ideal world we would have in, out and in/out parameters implemented with the same functionality as C#. I'd be very happy to have a breaking change to the compiler and migrate my code to such a language.
  21. David Heffernan

    Using uninitialized object works on Win32, throws AV on Win64

    Indeed. And it is simply the fact that var serves as both in/out and out that explains why there is no such warning for var parameters. Since we have out then a very simple thing for the designers to do would be to enable this very warning for var parameters too. If you encountered it on a var that was masquerading as a pure out parameter, you could simply change the parameter definition to be out.
  22. David Heffernan

    Using uninitialized object works on Win32, throws AV on Win64

    Without the compiler enforcing it, it's next to pointless
  23. David Heffernan

    Using uninitialized object works on Win32, throws AV on Win64

    The thing is, for value types, there is actually no practical difference between var and out in Delphi which is the problem. In practice out and var behave identically. So what's the point of out? I appreciate that legacy makes it hard to change. It was just a screw up by the designers that leads to oddities like the absent warning in this question.
  24. David Heffernan

    Using uninitialized object works on Win32, throws AV on Win64

    A variable has to be initialized before being passed to a ref param
  25. David Heffernan

    Using uninitialized object works on Win32, throws AV on Win64

    Because it has been designed correctly with ref, out and by value arguments handling the three different parameter semantics. C# is an example of how delphi should be, and the entire issue with this missing warning is because delphi is so badly designed in this area.
×