Leaderboard
Popular Content
Showing content with the highest reputation on 02/28/25 in all areas
-
Guidance on FreeAndNil for Delphi noob
Anders Melander replied to Paul Dardeau's topic in RTL and Delphi Object Pascal
I can't see that they do. Here's the TLDR as I read it: Allen is saying that you shouldn't (mindless or not) use FreeAndNil to solve logic/design bugs and AFAICT nobody is disagreeing with that. Primoz and David are saying that they are using it to find stale reference bugs. Allen's suggestion to use a debug memory manager instead isn't valid because you can't do that on a production system, as Primoz also points out. -
TParallelArray Sort Performance...
Vincent Parrett replied to Steve Maughan's topic in RTL and Delphi Object Pascal
@Stefan Glienke Looking forward to your talk at Delphi Summit 😃 -
shareware Some open sourced tools for Delphi developers
Patrick PREMARTIN posted a topic in I made this
Hi From the contacts I have from time to time following presentations or training courses, it seems that I'm better known for the video game coding part of my hobby than for the other stuff. It's true that I find it more fun (especially to stream on Twitch), but I also have utilities for Delphi developers created to simplify my life that I make available as binaries and source code on my GitHub account. App Stores Screen Captures Generator : to generate all the needed images from your screen captures when you have to publish your softwares on current app stores Copyright Pascal Projects : to add a copyright text in the header of each PAS/DPR files of a folder tree DProj To Windows Setup : to generate the Windows setup from Delphi deployment wizard data. It uses Inno Setup to create the install program and Exe Bulk Signing to sign the exe files. Exe Bulk Signing : a local and network signing program for Windows executables (exe+msix). It has an API you can use to integrate it in your projects like I did with "DProj To Windows Setup". Folder to FMX Image List : to create a FireMonkey TImageList to copy paste in your project or in a data module unit from all images in a folder tree. It fills the multires bitmaps depending on file names. Google Play Developer Banner Generator : to create a picture to use has your Play Store developer banner composed by a random collage of images you add to your project. I use it with icons of my Android apps. HTML Writer : to simply get HTML source code or WYSIWYG HTML content. I use Delphi HTML Components library in this program to have the WYSYWYG HTML editor and a memo for the source code tab item. Pic Mob Generator : my icons generator from basics layers or images, SVG, paths or rectangles. It export JPEG&PNG images, ICO and ICNS files. For the SVG I used RiverSoftAVG SVG Component Library, but next release will use Skia4Delphi. SM Code Generator : I use it in some multi players games, for EXE Bulk Signing API and client projects. The program generates Delphi code you only have to use in your projects to have a client / server solution to exchange formatted messages over IP. The library uses standard TCP sockets from Embarcadero (with no external dependencies). SVG Folder to Delphi Unit : to import SVG files as Pascal strings in your projects. I use it in some games with Skia4Delphi to show icons or sprites. The program generates a unit (compatible with Delphi 12.X and higher) with SVG found in a folder. Some of these programs are available from GetIt. The others will be submitted before the end of the year. The download links are on their GitHub repositories and will be added to their websites (which should be redirected to GitHub in the meantime). If you need changes in these programs or have suggestions, be free to tell here or as issues on their repositories. I'm also looking for ideas of simple tools to develop during live coding streams to show Delphi or web solutions. They are distributed as shareware programs. Contributions and sponsoring are welcome but not obligatory, and there are no program restrictions in the absence of a valid license. All features are available for free. -
shareware Some open sourced tools for Delphi developers
Patrick PREMARTIN replied to Patrick PREMARTIN's topic in I made this
I've just released HTML Writer v1.1 Changes : - added styles choice (light, dark, impressive, polar) - added languages choice (en/fr available, but this project has not many texts) - CilTseg has been enabled for activating the license and checking for new updates - the WYSIWYG editor has been updated with latest version of Delphi HTML Components Now this program uses my FMX Tools Starter Kit project. It's still a work in progress but you can check it on GitHub too. Like for the Gamolf FMX Game Starter Kit a more friendly documentation and some tutorials will be available one day (hope "soon" but who knows). The source code is available on https://github.com/DeveloppeurPascal/HTML-Writer You can download the binaries for Windows and Mac from the "releases" section. -
TParallelArray Sort Performance...
Stefan Glienke replied to Steve Maughan's topic in RTL and Delphi Object Pascal
Just a few new numbers of a not yet released parallel pdq sort - using the benchmark code from this comment earlier in this thread Fill array (double), elements count: 500000 Start sorting ... RTL TArray.Sort (ms.): 47 RTL TParallelArray.Sort (ms.): 35 Spring TArray.Sort (ms.): 12 Spring TArray.Sort_Parallel (ms.): 3 Fill array (double), elements count: 5000000 Start sorting ... RTL TArray.Sort (ms.): 551 RTL TParallelArray.Sort (ms.): 128 Spring TArray.Sort (ms.): 136 Spring TArray.Sort_Parallel (ms.): 64 Fill array (double), elements count: 100000000 Start sorting ... RTL TArray.Sort (ms.): 12724 RTL TParallelArray.Sort (ms.): 1884 Spring TArray.Sort (ms.): 3035 Spring TArray.Sort_Parallel (ms.): 675 Again - these numbers are fluctuating a bit because the benchmark is a "run once" benchmark and it depends on the current CPU state etc - also I did not tweak the threshold and CPU count yet - simply calling TTask.Run from System.Threading to fork some slices into parallel execution. But overall it does not look too bad, doesn't it? -
Guidance on FreeAndNil for Delphi noob
David Heffernan replied to Paul Dardeau's topic in RTL and Delphi Object Pascal
This one is easy to debunk. Exceptions raised in a constructor then lead to exceptions in the destructor. This is the entire reason why Free exists. -
Guidance on FreeAndNil for Delphi noob
Stefan Glienke replied to Paul Dardeau's topic in RTL and Delphi Object Pascal
Using FreeAndNil is the very essence of https://en.wikipedia.org/wiki/Cargo_cult_programming -
Guidance on FreeAndNil for Delphi noob
Dalija Prasnikar replied to Paul Dardeau's topic in RTL and Delphi Object Pascal
For me it is about code intent. FreeAndNil implies reusable variables and more complex instance lifetime. Free implies the opposite. -
Since you are developing for mobile. DO NOT run blocking tasks in the main UI thread, it must service only the UI. Long-running tasks must be done in the background instead. In your case, you have a LONG-running task (5.5 seconds) that blocks the UI until the task is finished. Tokyo let you get away with it using a hack. Rio doesn't. So just don't do it anymore. You need to change the code (even for Tokyo) to work with the main UI thread correctly, stay away from ProcessMessages() at all costs (especially now that Embarcadero has broken it and doesn't want to fix it). Do things asynchronously so flow returns to the main UI message loop in a timely manner (otherwise Android is likely to kill your app!). For example: procedure TForm2.Button1Click(Sender: TObject); var StartTimer: TProc; begin ProgressBar1.Max := 100; ProgressBar1.Value := 0; StartTimer := procedure begin Timer1.Interval := 500; // <-- can be set at design-time Timer1.Enabled := True; end; {$IF CompilerVersion < 33} // 10.2 Tokyo or earlier TabControl1.TabIndex := 1; StartTimer; {$ELSE} // 10.3 Rio or later TabControl1.SetActiveTabWithTransitionAsync(TabControl1.Tabs[1], TTabTransition.None, TTabTransitionDirection.Normal, StartTimer); {$IFEND} end; procedure TForm2.Timer1Timer(Sender: TObject); begin ProgressBar1.Value := ProgressBar1.Value + 10; if ProgressBar1.Value >= ProgressBar1.Max then Timer1.Enabled := False; end; Yes, sorry about that. Fixed above. What is there not to understand? The TTabControl is transitioned to the desired Tab and a timer is started, then flow is returned to the main UI message loop. When the timer fires after 500ms, the ProgressBar is incremented and flow is returned to the main UI message loop. The timer fires again after another 500ms, and again, each time returning to the main UI message loop. Eventually, the ProgressBar reaches its Max and the timer is stopped.
-
This is definitely not the right way to write code. Avoid ProcessMessages() whenever possible. The example given can be replaced with a simple UI Timer instead, eg: ProgressBar1.Value : =0; ProgressBar1.Max := 100; Timer1.Enabled := True; ... procedure TForm1.Timer1Timer(Sender: TObject); begin ProgressBar1.Value := ProgressBar1.Value + 1; if ProgressBar1.Value >= ProgressBar1.Max then begin Timer1.Enabled := True; Exit; end; //... end; But, if your real project is using the ProgressBar to tracking status of actual tasks, those tasks should be done in the background, and updates to the UI synced with the main UI thread accordingly.