- RAD Studio Hotfixes for XE8 and XE7 with 10 Seattle fixes
- Enabling AUTO_CLOSE is a bad idea?
- How to get information, help and support when you need it - there are several ways.
- Delphi 2016 Roadmap
- Buy One Embarcadero Developer Tool and Get Another Tool Free - Until Feb 29, 2016
- Delphi Blogs of the Week/Month #38
- Blog UI Redesign in Progress
- Editing Delphi Code on a Mac
- Facebook Email: Important Parse Announcement - will be fully retired ending on January 28, 2017
- Delphi TouchID wrapper for iOS
- DFMCheck 1.6 released
- Videos that will help you move your Delphi, C++Builder and RAD Studio projects forward!
Yesterday Embarcadero has released two hotfixes for RAD Studio XE7 and RAD Studio XE8 including a number of bug fixes that have already been made available in RAD Studio 10 Seattle.
This effort is part of the Update Subscription benefits (the fixes are made available only to Update Subscription customers) and it is tied to the request coming from customers of increasing the support for older versions.
Here are the CodeCentral download links:
As you can see from the names, these updates have been in development and QA for a little time, but it took some extra effort to ensure their quality.
At the very bottom of the two pages above you'll see the list of fixes covered by each of the two hotifes. These fixes are in many different areas of the tool, from RTL to VCL, from mobile to FireDAC. Notably there is improved support for iOS 9, OS X El Capitan and Windows 10 for the older versions of RAD Studio. There are also some significant fixes to the XE8 generic TList and TListHelper.
The RAD Studio roadmap for 2016, including plans for Delphi and C++Builder for the current year, is now public. You can find it at:
As you can see, there is a lot of ongoing development and some great releases coming soon. The best way to get them? Buy 10 Seattle now (unless you already have it) along with 1 year of Update Subscription.
This is far from complete list of what's coming, and highlights only the main themes. If you are looking forward for other features, feel free to post your suggestions to Embarcadero Quality Portal or reach either myself or any of the other RAD Studio Product Managers. As always comments are welcome also here and on the community site, but no flames, please.
Here is another round up of interesting links and blog posts for Delphi developers, over the last couple of weeks. Meanwhile the blog UI redesign continues, but it is still much of a work in progress.From Embarcadero
Skill sprints at https://www.embarcadero.com/landing-pages/skill-sprints
New Bogo (Buy One Get One) offer at http://www.embarcadero.com/radofferTechnical Blog Posts
A Splash Form in FireMonkey by Uwe Raabe at http://www.uweraabe.de/Blog/2016/01/22/a-splash-form-in-firemonkey/
Videos that will help you move your Delphi, C++Builder and RAD Studio projects forward by David I at http://community.embarcadero.com/blogs/entry/videos-that-will-help-you-move-your-delphi-c-builder-and-rad-studio-projects-forward
On Conditional Compilation by Uwe Raabe at http://www.uweraabe.de/Blog/2016/01/22/on-conditional-compilation/
Decompressing the TRESTResponse by Jim McKeeth at http://delphi.org/2016/01/decompressing-the-trestresponse/
Delphi TouchID wrapper for iOS by David I at http://community.embarcadero.com/blogs/entry/delphi-touchid-wrapper-for-ios
More windbg tricks with Delphi how to ignore specific exceptions by Marc Durdin at https://marc.durdin.net/2016/01/more-windbg-tricks-with-delphi-how-to-ignore-specific-exceptions/
Hacking The Android JNI To Add MultiLine Notifications For Firemonkey In Delphi 10 Seattle by FMXExpress at http://www.fmxexpress.com/hacking-the-android-jni-to-add-multiline-notifications-for-firemonkey-in-delphi-10-seattleThird Party
Cool new FMX components by Graham Murt @kscomponents, see http://community.embarcadero.com/blogs/entry/cool-new-fmx-components-by-graham-murt-kscomponents and directly at https://github.com/gmurt/KernowSoftwareFMX/blob/master/README.mdWritten in Delphi
Non Stick Mouse in corners of Windows 10 by Jonathan Barton at http://www.jawfin.net/?page_id=143
As you might have seen if you visited my blog during the last two days, I'm in the process of a complete redesign of the blog user interface.
I'm moving from a totally custom CSS style written when I first built this blog, in September 2005, to a Bootstrap-based web site. I started from a rather standard blog design from the Bootstrap demos, and done some limited touching. I'm really expecting to go beyond basic functionalities, but I have still quite a few features to implement, like a folding side menu, cleanup of a few links, and more.
I have not migrated the blog to a new engine, as keeping all of the existing content and links won't be easy. So this blog HTML rendering is still powered by XSLT and is based on XML data structures generated by a Delphi-powered application.
I hope you'll appreciate the results... but unless you see something totally broken, please wait reporting issues for a few more days, while I'm finishing the work.
Over the last year, there has been an increasing push in the development of source code editors and even full development environments based on portable code and available on multiple platforms, including Mac OS X. Here are some notes about my experiments with Object Pascal enabled editors on the Mac.
Microsoft entrance into the area of cross platform hosted development tools made a significant splash last year. Visual Studio Code is a very interesting project, mainly oriented to development with scripting languages and web technologies, but with capabilities that go well beyond those of an editor. While not a replacement of Visual Studio for C# development, it works pretty well on Mac OS X and has a couple of Object Pascal language extensions (among many others). Being backed by Microsoft, makes this project highly visible. Some links:
- The main Visual Studio Code page is at code.visualstudio.com/
- The OmniPascal plugin is available at https://marketplace.visualstudio.com/items?itemName=Wosi.omnipascal and more information is available on the project web site at www.omnipascal.com/. The main limitation is that all of the features beyond syntax highlighting currently work only on Windows (and they also don't support fhe full Delphi Object Pascal language)
- The simpler Language Pascal plugin offers only core features and is available at https://marketplace.visualstudio.com/items?itemName=alefragnani.pascal.
Below is a screenshot of some Delphi code on my Mac in Visual Studio Code.
Another very interesting open source and cross platform editor is Atom, which is backed by GitHub. Atom is more of an editor than a full development environment, is focused on customization (or hack-ability), and is extremely fast. There are Object Pascal language bindings also for it (done by the same developer of the Pascal VSCode plugin). Links:
- Atom main site is at atom.io/
- A very nice overview is at www.jonobacon.org/2015/11/16/atom-my-new-favorite-code-editor/
- Atom Pascal bindings can be found at github.com/alefragnani/atom-language-pascal
And here is a screen shot, with the same Delphi source code file.
- Trolledge site is www.trolledge.com/
- The source code repository is at github.com/FMXExpress/Trolledge
As you can see in the image below, opening a form automatically opens the matching designer in a second text editor. This is the only editor with a core knowledge of Delphi and its language and architecture.
What's Your Take?
Have you used any and what's your experience? Which one do you like most? And do you think taht Embarcadero as a development tools company should invest in this area alongside with improving and modernizing the RAD Studio IDE on Windows?
I've migrated the demos of most of my books, from a hosted SVN repository (at code.marcocantu.com/) to GitHub, in a new organization called MarcoDelphibooks, at github.com/MarcoDelphiBooks. In my code site, I had a single repository for older books, and one for the Object Pascal Handbook. On GitHub I decided to create separate repositories, making it easier to grab only what you need and even download a single ZIP for the entire project.
In the migration process, I cleaned up only the Object Pascal Handbook repository, recompiling all demos with Delphi 10 Seattle, and I plan to keep them up to date with the latest release of Delphi going forward. Other books are version specific, so it makes more sense to keep the original demos as they were and as they compiled in the version they were created for. I might create separate repos for collection of demos for different product areas (VCL, RTL, Database) updated for the latest Delphi, but that's a separate project.
Hope this helps making them more reachable and easier to interact with. In the short term, I plan moving also my other demos repositories (still at code.marcocantu.com) to 10 Seattle and to GitHub, and look also for demos of older books and publish them as well. I plan closing my personal, paid, subversion hosting site ASAP.
I'm still far from a Git and GitHub expert, and welcome any feedback, interaction, suggestion.
Let's start the new year (after some days off) with a new round of interesting links and news.New Year at Embarcadero
The 2015 Embarcadero Year in Review by David I at community.embarcadero.com/blogs/entry/the-2015-embarcadero-year-in-review-by-david-i
Planning for a great 2016 by Atanas (Embarcadero General Manager) at community.embarcadero.com/article/news/16208-planning-for-a-great-2016
Appmethod Merges with RAD Studio Product Line at community.embarcadero.com/article/news/16209-appmethod-merges-with-rad-studio-product-line
Looking for a (possible) future? Baking an Object Pascal and Raspberry Pie for the Holidays by Allen at blog.therealoracleatdelphi.com/2015/12/baking-object-pascal-and-rapsberry-pie.html
Even if not coming from Embarcadero officially, this is a great post on the status of the Delphi, by Bruce McGee, at glooscapsoftware.blogspot.it/2015/12/the-state-of-delphi.htmlTechnical 10 Seattle Blog Post
Using LocationSensor on Android Service in Delphi Seattle by Daniele Spinetti at www.danielespinetti.it/2016/01/using-locationsensor-on-android-service.html
Trimming The Fat - Smaller Windows .exe Sizes With Delphi And C++Builder by Briand Long at blong.com/Articles/TrimTheFat/
Windows applications: Icons and the Shell; names, sizes, etc. by Jeroen at wiert.me/2015/12/23/windows-applications-icons-and-the-shell-names-sizes-etc/
There Can Only Be One! by Uwe Raabe (very nice description on the role of desing time packages) at www.uweraabe.de/Blog/2015/12/23/there-can-only-be-one/
Newsgroup Nugget: Row-level locking with FireDAC by David I at community.embarcadero.com/blogs/entry/newsgroup-nugget-row-level-locking-with-firedacThird Party
FirePower by Wool2woll updated, see www.woll2woll.com/woll2woll-firepower.html
Looking for a Delphi job or a developer, see (among others) www.delphijobsboard.com/0/And Some Fun Tidbits
Delphi trending up on Tiobe index (www.tiobe.com/index.php/content/paperinfo/tpci/index.html) and did very well on Code 2015 (code2015.herokuapp.com/), but these are honestly limited views on the developers world. If you are a developer (using Delphi or not) you can get counted on a more realistic survey by stackoverflow at www.surveymonkey.com/r/so-2016.
But the other think you should not miss is the latest Verity Stob column, not on Delphi but on functional programming. "Remember the Monoids" is a great read at www.theregister.co.uk/2016/01/13/stob_remember_the_monoids
The Embarcadero Quality Portal (https://quality.embarcadero.com) now offers specific support for requesting new features for RAD Studio. There is a new issue type "New Feature", beside Bug and Documentation Bug. The fields to fill in a slightly different (like there are no steps), but most of them should be familiar to anyone who has reported bugs. The three issue types for the RAD Studio Project in Quality Portal are visible in the image below.
The new features have a specific flow of operations.
For regular bugs, once they are reported and sent to the internal JIRA system, a QA (Quality Assurance) developer will either ask for more information or approve it and assign to a developer. Later the team will determine the update or release the issue should be fixed.
For new feature, reports get into the internal system and are assigned to PM (Product Managers) who will use them to create the plans for future releases, adding them to an appropriate activity (or Epic, in JIRA terms), attaching a priority, and determining in which release the feature should be implemented. Other options are to indicate there is no plan to implement the feature (closing it) or to put in "on hold" for future consideration. In the first case, this will be reflected immediately in the status of the report, while in the second case the issue will stay open.
There is one more flow, which is very important right now. When a customer reports a bug, the team can determine it is really a new feature request (as it goes beyond the scope of the existing feature). We can change the internal status and this will be reflected in a change from Bug to New Feature in the Quality Portal.
Of course, we'll have to do this for all past issues that have been reported with the bug type, even if they were marked as feature requests in the title or description. We've already started the process, you can see as an example quality.embarcadero.com/browse/RSP-9400, and expect to go over it within a couple of weeks. If you suggested features, you should expect such a notification for your report. Let me know if this doesn't happen. We'll also change the category for issues intended as bug reports: If you disagree let us know. Ultimately, if an issue is a bug or a feature request it doesn't really change the timing for its resolution.
This change should help improve managing feedback from our customers, and even improve our internal workflow. I know this will please many of you who requested it. As a side effect, it will make the separation between feature work and bug fixing (like for an update) more obvious.
Another month has gone by, and here are some interesting Delphi links I've collected.Embarcadero Updates
New Platform Status docwiki page, indicating support for newely released versions of the operating system RAD Studio supports, and offering workarounds and suggestions from blog posts and other sources: docwiki.embarcadero.com/PlatformStatus/en/Main_Page
10 Seattle Update 1 has been released with new features (blog.marcocantu.com/blog/2015-december-features-10seattle-u1.html) and bug fixes (blog.marcocantu.com/blog/2015-november-radstudio-10seattle-udpate1.html). There are also two follow up hotfixes (blog.marcocantu.com/blog/2015-december-2-hotfixes-10seattle-u1.html)
If you don't have 10 Seattle check out the active offers at www.embarcadero.com/radofferGeneral Blog Posts
Jens Fudge on Teaching Delphi at delphi.exotech.dk/#post36
Stephen Ball video in Visual Live Bindings (Master Detail Detail) at https://www.youtube.com/watch?v=N7z3wPjgZEI&feature=youtu.be&a (part of a series worth looking to)
Allen Bauer on assorted topics like his guru-maker experiences (Cyborging a Cheap Laminator) and meeting one of his mentors (blog.therealoracleatdelphi.com/2015/12/mentors-and-inspiration.html)
Sarina DuPont on accessing a WinRT API for globalization at community.embarcadero.com/blogs/entry/using-the-winrt-globalization-api
Jim McKeeth on Hour of CodinGame with Object Pascal / Delphi at delphi.org/2015/12/hour-of-codingame-with-object-pascal-delphi/Really Technical, In Depth Blog Posts
Favorably surprised by the depth of many recent blog posts, including the following:
Marc Durdin has a summary blog post with links to articles he wrote covering Windbg and Delphi at marc.durdin.net/2015/11/windbg-and-delphi-a-collection-of-posts/ (I remember using Windbg to find nasty errors in the past)
Sarina has also a long and detailed comment in a quality portal bug report regarding support for iPad Pro device and detailed steps on how to add a launch storyboard to a FireMonkey application at quality.embarcadero.com/browse/RSP-12931
David Millington has a very nice blog on "Custom object memory allocation in Delphi: Bypassing FastMM for fun and profit" at parnassus.co/custom-object-memory-allocation-in-delphi-bypassing-fastmm-for-fun-and-profit/ (I covered this on my Robust Delphi applications sessions years ago, but I agree this technique is largely unknown).Delphi Tools
The Delphi Parser is a new tool to help migration, with the current version focused on BDE to FireDAC migration. A free tool let's you assess the actual conversion on your code. The company also offer migration consulting.
A solar calendar open source VCL component at sourceforge.net/projects/solarcalendar/Conclusion
Have a nice reading. I'll try to create another of these blog links collections before the end of the year.
Among several changes and sales initiatives happening at Embarcadero during this month, there are two worth underlining and both related with the components the company acquired this year from Raize software, Konopka Signature VCL Controls and CodeSite Studio. I probably don't need to spend too much time extolling the virtues of this set of high-quality controls, with superb integrated designers, and of the complete version of CodeSite, many of you use in the feature-limited version that ships with the IDE.
What I want to point out in this blog post is that Embarcadero decided to permanently change the pricing structure of both add-ons, with a first year fee now already including 1 year of updates, a lower yearly renewal, and a simplified upgrade pricing. The savings are quite substantial, so if you were considering the tools and decided not to buy because of the price, it is worth reconsidering and checking the new offer on your local Embarcadero online store or with your local reseller.
The second initiative related with these add-ons is for anyone looking forward to buy a license of Delphi, C++Builder or RAD Studio 10 Seattle, either new or upgrade. As you can read on www.embarcadero.com/radoffer if you buy the Professional, Enterprise or Ultimate editions the Konopka Controls and CodeSite Studio will be free, while if you buy you the Architect edition you get for free the entire RAD Solution Pack, worth several thousand Dollars or Euros. Act now, as these offers expire on December 18th.
For two videos introducing the components and a different angle on these offers, see also community.embarcadero.com/blogs/entry/these-are-the-components-you-are-looking-for.
While the Update 1 of RAD Studio 10 Seattle had a significant number of issues addressed (see for example my announcement in the blog), it has also some interesting new features or improvements to existing features, that go beyond bug fixing. While in some scenarios it is quite obvious, in many cases it is difficult to draw a strict distinction between a bug that is fixed and a new feature that is added, particularly when it is a matter of improving an existing feature. In both cases, the net result is improving the product and enabling a capability that wasn't working, either by design, to meet a deadline, or by mistake.
This is a list I've gathered looking throughs the work that was done by the team for the 10 Seattle Update 1, with most features equally applying to Delphi and C++Builder:
- Improved drawing of main menu and form borders, under Windows 10, for VCL styled applications. On a similar note, the styled common dialogs now properly support local menus.
- The IDE now uses HTTPS to connect to the community site, handle community login, and communicate with the remote server.
- Additional demos have been added to the 10 Seattle repository
- The IDE reintroduces support for C++ Code Formatting, which had to be reworked because of C++ compiler changes
- AppAnalytics connections use HTTPS instead of plain HTTP for security
- The IDE and PAServer offer additional support to deployment of apps on iOS 9 (including better handling of Apple Transport Security feature)
- PAServer offers additional support to deployment of apps on OS X El Capitan (this was available in preview to all customers)
- The AppTethering encryption hooks have been significantly reworked and improved
- There have been improvements to the FDMemTable FireDAC component, for better ClientDataSet behavior compatibility
- The REST client library now supports passing empty URL parameters in TRestClient calls, a feature that was important to offer compatibility with previous DataSnap REST clients behavior
- The installation will now install the latest version of Java (Java 8) as a pre-requisite, if the Java runtime is not found on the target systemThese are changes that to me fall more into feature work than bug fixing, but your mileage might vary. We are committed to keep improving RAD Studio 10 Seattle, offering continuous improvements and bug fixes to the customers who've embraced Update Subscription.
Today we released two separate hot-fixes for RAD Studio, Delphi and C++ Builder 10 Seattle Update 1.
The first has replacement C++ CLANG compilers for the international versions of the product. The English version is not affected by the problem. The download is at http://cc.embarcadero.com/item/30454
The second is a fix to a GDI resource leak in the Modern Themes package, that would slow down the IDE over time. In this case the issue affects all versions and all customers. This second fix can be downloaded from http://cc.embarcadero.com/item/30453
I want to personally thank the RAD Studio Development and QA team for working on these issues promptly and provide a solution in a short amount of time.
PS: Thanks also to the Delphi community for reporting, tracking and isolating the issue and helping us nail it down faster
This is a new webinar for C++ developers to move your development forward before the new year, focused on C++ developers and migration to the new LLVM Win32 C++ 11 compiler.
David I, JIm McKeeth, and other Embarcadero evangelists an experts will do the presentation, which is expected to focus on:
- How to quickly migrate your C++Builder projects to C++Builder 10 Seattle
- Update Your Apps UI/UX with the All New Windows 10 Look and Feel
- C++11 language features for Win32, Win64, iOS and Android apps
- Application Tethering for VCL and FireMonkey using C++
- Enterprise Mobility Services - Creating EndPoints, Push Notifications and Custom Logins
- MultiThreading with System.Threading for Mobile and Desktop Apps
- Proximity base development with Beacons and BeaconFence
- and more…
For more information and to register read the following page and follow the registration link:
Moreover, also fhr C++ developers, we'll have a small set of skill sprints in December, read more at community.embarcadero.com/blogs/entry/three-new-c-developer-skill-sprints-in-december-2015-join-the-c-11-fun
C++Builder Seattle is really a huge step forward for C++ developers who want to visual development environment, working across platform, and based on the latest C++ language standards. If you do any C++ work, don't miss this webinars! And if you don't have C++Builder 10 Seattle, there are now great offers to take advantage of.
The update is now available for download. This update consists of over 250 bug fixes, including fixes to 70+ customer-reported issues -- see the list at edn.embarcadero.com/article/44619. Almost all of these 70+ customer reported bugs come from Quality Portal, http://quality.embarcadero.com, and include the 5 top voted issues specifically opened for 10 Seattle (and among the most voted overall). Here are the download links:
The update includes the following notable fixes (some of which are specific to Delphi or C++):
- Win64 compiler bug causing indeterministic behavior (RSP-12512, this issue was also previously addressed with a beta hot fix available to all registered users)
- DataSnap REST client call issues due to the switch to the HTTP client library (RSP-12685)
- DBGrid columns sizing bugs (like RSP-12433, RSP-11797)
- High-resolution monitor and tabbed dialog handling (RSP-12332)
- C++ 32bit CLANG compiler issues (like RSP-12250 and RSP-11883)
- Themed common dialogs (RS-11814)
- TPushEvents Android exception (RSP-12347)
Notice that these bugs will be marked as closed in QP in a few days, along with all other bugs that are closed as fixed or as duplicate of other bugs that have been fixed. The process is automated but requires manual overview...Re-Install, Only For Subscription Customers
Two more tidbits. First, this update is a full uninstall/re-install. As usual the reason is this update touches such a large number of files, that individually updating those files won't really save any time (it will be much slower, in fact), but facing more risk of errors. You might have seen the size of the recent 64bit compiler hotfix.
Second, as the name implies and as already happened for XE8 and part of Embarcadero policy since the beginning of 2015, the Update is available only to active Update Subscription customers. If you own a 10 Seattle license without Update Subscription don't try to install it: you'll have to re-install the original version. What you can do is add the Update Subscription to your current license, contacting sales or a reseller partner. The standard limitations for buying Subscription only with or immediately after the product have been waived, so any 10 Seattle customer can now buy the Subscription for the next couple of weeks.The Most Stable RAD Studio RAD Studio 10 Seattle was a very stable release, and with this further Update is really becomes a version that's hard to miss for any C++Builder or Delphi developer! And if you still haven't bought 10 Seattle, you can take advantage of the current, incredible offers that provide you free high-quality components (RAD Solution Pack, Konopka Controls or CodeSite, depending on the SKU) with your license. Read more at www.embarcadero.com/radoffer. Update: ISO Link
The ISO download is now at cc.embarcadero.com/item/30446
I just realized it has been almost two months since my last collection of links, but I did blog quite a bit with the most important ones anyway. Still, welcome back to this collection of links, blogs, and other information you might have missed. here is the list, with no specific order:
- Changes in Quality Portal component's list and some hints at community.embarcadero.com/blogs/entry/changes-in-quality-portal-component-s-list (by Juan Antonio)
- Important Note about using the Google Maps API from Desktop Apps at theroadtodelphi.wordpress.com/2015/10/19/important-note-about-using-the-google-maps-api-from-desktop-apps/ (by Rodrigo)
- Using the Network List Manager (NLM) API from Delphi at theroadtodelphi.wordpress.com/2015/10/28/using-the-network-list-manager-nlm-api-from-delphi/ (also by Rodrigo)
- TRichEdit behaves differently under Unicode at chapmanworld.com/2015/11/04/trichedit-behaves-differently-under-unicode/ (by Craig)
- Using QueryLines to filter your BaaS data at community.embarcadero.com/blogs/entry/using-querylines-to-filter-your-baas-data (by Sarina)
- (even if not strictly Delphi, still related) Migrating legacy C++ Builder Apps to C++ Builder 10 Seattle at community.embarcadero.com/blogs/entry/migrating-legacy-c-builder-apps-to-c-builder-10-seattle (by Al)
- Android Services Presentations and Workarounds at delphi.org/2015/10/android-services-presentations-and-workarounds/ (by Jim)
That is all for this round. Maybe I should get back to my old model of sharing my Twitter retweets and Favorites on the blog... and do it more timely. But I'll probably just try to get back to a monthly list.
This blog post delves into some technical information about ARC and the available types of references in the Delphi mobile compilers for iOS and Android. The reason for this blog post is that there has been very little technical information about this topic and I've personally only recently come to realize -- in conversations with Embarcadero developers, particularly Allen Bauer -- some of the implications (so that my Object Pascal Handbook, while correct, can be considered incomplete).
Here I'm not going to repeat all of in the information already in my book and other sources, but provide a short overview and focus on the latest part, unsafe references, which is the most neglected one so far.What is ARC?
Automatic Reference Counting is a memory management model based on tracking the references to a single object in memory and disposing the object in a fairly deterministic way when all references go out of scope. Unlike garbage collection, ARC happens in the thread of execution and in synch with the program flow, even if the flow can be fairly complex to easily understand when each given object will get deleted. (Not that here I want to delve into the merits of ARC vs. GC, this could be a whole different blog post). ARC is the standard memory model for Apple programming languages on both OS X and iOS.
Delphi mobile compilers all embrace ARC as the primary model, with ways to mitigate the transition from the traditional memory model thanks to extra methods built into the TObject class. When all references to a Delphi object go out of scope, the object is deleted and its destructor called. You can set a reference to nil in advance, to make this happen sooner, and even force the execution of the destructor in advance (calling DisposeOf).
Again, a lot has been written about ARC and ARC in Delphi, and I don't really have too much to add here.What is a Weak Reference?
Weak references are a fundamental element of the ARC model. With ARC, unlike a GC, there is no loop detection so you need to "break" any loop using a weak references. This is something I cover in my book, I wrote about in white papers, and that is documented in several other sources. The implication of weak references is that these are managed. The system tracks all pending weak references, and if an object is destroyed and there is a weak references pending, this is automatically set to nil. This way you can check if a weak reference is nil to verify the object the weak reference is pointing to is still in memory -- something not available with the traditional memory model. The management of weak references has a runtime cost (although this cost is lower in Delphi than in Apple's implementation), as the system need to store them and track them. A large number of weak references might become expensive at runtime.
Can we skip using weak references altogether and use a manual, traditional approach? This is certainly a possibility, as explained below, however if you need to set up another complex object destruction notification system of your own, you might end up with a system that implies writing more code and have a larger runtime penalty compared to weak references.What is an Unsafe Reference?
The last element, and the main point of this entire blog post, is the existence of unsafe references. There are a few documented examples of their use (including in my book) mostly focused around the scenario of handling temporary objects. A classic example is that of a function creating and returning an instance. At the point the function returns and before the object is assigned to another variable (for example as the result of an expression) the instance might end up with exactly zero references, and could be subject to (unwanted) disposal.
However, unsafe references can be useful in other scenarios. You declare one with the unsafe keyword, or (even better) the [unsafe] attribute. You can use this attribute to decorate a local variable or a field in a class or record.
What is in essence an unsafe reference under ARC compilers? It behaves basically as a traditional non-reference-counted reference of the Delphi world. No increase or decrease of the reference count happens when an unsafe reference is assigned an object or goes out of scope. No check for zero references is performed. Just like with a "good old" Delphi reference. (Along the same line mixing unsafe and ARC references can get you in some tricky scenarios, more or less like mixing interface and object references on the Windows compilers).
Does this mean developers should scrap ARC and go for the traditional model? To me this does make sense in some very specific scenarios, in which another memory management model is already in action. In general, ARC is a very powerful and complete model I recommend understanding and embracing, rather than fighting. Make sure you learn your options, and than make an decision, rather than taking a shortcut to the scenario you know from the past.
Consider also that our entire library uses ARC and weak references (although some of those might end up moving to unsafe references in the future).A Roundup Micro Demo
To round up the blog post, let me finish with a very simple code demo, to highlight in less than 10 lines of code the differences between regular ARC references, weak references, and unsafe references. Consider this code snippet:var myObj: TMyClass; myObj2: TMyClass; [weak] myObjW: TMyClass; [unsafe] myObjU: TMyClass; begin myObj := TMyClass.Create; Show(myObj.RefCount.ToString); myObj2 := myObj; Show(myObj.RefCount.ToString); myObjW := myObj; Show(myObj.RefCount.ToString); myObjU := myObj; Show(myObj.RefCount.ToString); myObj2 := nil; myObj := nil; // frees the object // are references still (apparently) valid? Show(Integer(Pointer (myObjW)).ToString); Show(Integer(Pointer (myObjU)).ToString); end;
The program creates an object with two regular (ARC) references plus a weak and an unsafe one. The reference count is displayed each time. Later the two main references are set to nil (effectively freeing the object), and we look at the raw pointer value of the two "pending" references, the weak and the unsafe one. Can you guess the output without looking to the image below?
As you can see, the weak reference is automatically set to zero (so you can do an if Assigned test before using it), while the unsafe reference becomes in all effects a dangling reference, a reference to the memory location where the object used to be (before being destroyed). Using that reference is bound to incur in errors and it is very difficult to determine at run time if that reference is indeed valid. Which is the main reason for using a weak reference in the first place.
Of course, the point of using weak and unsafe references is in managing very complex data structures, but this small snippet should convey the key technical differences among these three reference types, underlying the fact that they behave in a significantly different way. I hope this blog post helps shed some light.
While giving a session on FireMonkey architecture yesterday at EKON, we got to the subject of alternative configuration for the direct paint operations, using the GPU in different ways. To demonstrate that on different platforms the Canvas object you use for painting is different, I added to an empty FireMonkey form the following OnPaint event handler:procedure TFormFMtoGPU.FormPaint(Sender: TObject; Canvas: TCanvas; const ARect: TRectF); begin Canvas.Fill.Color := TAlphaColorRec.Blue; Canvas.Font.Size := Height div 3; Canvas.FillText ( ARect, Canvas.ClassName, True, 1, , TTextAlign.taCenter); end;
If you run this FireMonkey applications on different platforms, you'll see different Canvas objects are going to be used:
- on Windows, by default, you get TCanvas2D2 (for Direct2D support)
- on the Mac, you get TCanvasQuartz (Quartz is the OS X GPU library)
- on mobile platforms, both iOS and Android, you get a TCanvasGpu
This "GPU Canvas" is a way to send graphic commands to the GPU directly, bypassing an operating system stack which is not always very efficient. Now what it less know is that you can use the same GPU Canvas also on Windows, by forcing it with the global setting FMX.Types.GlobalUseGPUCanvas to True in the project source code before the application object is initialized. On Windows there is also the option of disabling DirectX and using the GDI+ fallback, generally a slower solution with much worse anti-aliasing effects. This is achieved by setting to False the global setting FMX.Types.GlobalUseDirect2D . In other words, on Windows you have 3 separate options.
For more information, you can read the following:
The session at EKON was mostly focused on styles in FireMonkey, however a developer in the audience was able to tweak the canvas and get an application working on a rather old PC, so I though it was worth sharing the tip.
Following the XE7 counterpart, there is now a hotfix available for RAD Studio XE6, called "October 2015 XE6 Update Subscription Update". This includes a subset of the issues fixed in the recent XE7 hotfix. Again, this hotfix is available only to Update Subscription customers, as an extra bonus for our most loyal customers.
As we covered a few times, Update Subscription is your way to stay current with the products and also have fixes for recent past versions. We understand that even if you have the latest version available you cannot migrate immediately and cannot migrate all of your applications. While newer versions offers many significant enhancements in many areas of the product, and we certainly want to encourage everyone to move to RAD Studio 10 Seattle, having project on older versions with a few issues fixes can be beneficial.
So if you bought XE8 with Update Subscription you can head to
download and install. If you started update subscription with 10 Seattle, you can also download the package, but you might have to refresh your license in License Manager (at least over the next few days) before you can apply the fix. The installer, in fact, checks for a specific update subscription + license combination. By the way, the same applies to the XE7 fix: we are doing some final testing and will explain the actual steps as soon as possible.
Finally, the team is also working on an XE8 Update including some of the fixes introduced in 10 Seattle. And also working on the first main Update for 10 Seattle itself. These updates will also be limited to Update Subscription customers: If you bought 10 Seattle recently you might still have time to add the Update Subscription to it!
Next week I'll be speaking at the 19th EKON conference in Germany, a rather large Delphi-focused event with tracks in German and in English, and many top quality speakers.
EKON, entwickler-konferenz.de/2015/en, is one of the longest standing Delphi events, now in its 19th edition (even if originally it was a multi-technology developer conference). The conference runs November 2nd (Monday) to 4th (Wednesday) in Koeln (or Cologne), Germany. The location is a minute from the main train station, very easy to reach.
There are two speakers coming from the US (Cary Jensen and Nick Hodges), many well known German and European speakers, an Embarcadero presence with myself and Matthias Eissing. I'll give a keynote on Delphi 10 Seattle and the product status in general, and also two technical sessions on VCL/Windows 10 and on FireMonkey.
EKON is generally a very nice event for networking with other developers, chat over a beer, and have some fun. If you are coming, I'll be available for a chat, for a meeting with your team, or anything else. I can also bring printed copies of my latest Object Pascal Handbook, if you want one signed -- but let me know in advance.