Showing posts with label CPlusPlus. Show all posts
Showing posts with label CPlusPlus. Show all posts

Thursday, 8 April 2021

Installer tip

I'm really enjoying RAD Studio 10.4.2, but my journey with it got off to a less than wholesome start. I'd installed from the .iso download and put just a basic Windows platform support in. Shortly thereafter I wanted more target platforms installed so I chose Tools, Manage Platforms... and was disturbed to see this message:


O NOES!!11111!1!!!one!! (or some other geeky response)

Fortunately there was no corruption. This post is simply to pass on the tip of what to do if you happen to see this, instead of following the knee-jerk reaction of immediately uninstalling and reinstalling.

The issue here is misinformation. It's not necessarily corrupted at all - the installer displays this message if it cannot find the installation database file. When you installed RAD Studio the location of the installer file is written to the registry within this key:

HKEY_CURRENT_USER\SOFTWARE\Embarcadero\BDS\21.0\CatalogRepository

The value ServicePath in that key points to a .gof file, in my case F:\radstudio_10_4_esd_104203a.gof. The thing is, I installed from a .iso file, which I mounted to a drive (F:) at the time and had since unmounted, ∴ that path no longer reached anything. Unfortunately the installer responded inappropriately: misinformation.

I gather this issue will be fixed for the 10.5 installer, but hopefully this saves someone the trouble of an uninstall and reinstall at some point.


Tuesday, 20 October 2020

Deleaker: memory / resource leak detection and identification

As I've made clear many times in conference talks I’m a big fan of FastMM4, the full version Delphi’s built-in memory manager (I haven’t yet tried out FastMM5, which is fully rewritten but now has either a GPL or a commercial license). FastMM4 is great for identifying memory leaks, memory corruption, interface misuse and so on, and locating the source of the problem via a call stack. However it is true that the business of working through the FastMM4 reports is somewhat manual – reports and call stacks are sent out via debug strings or log flies and then you have to pore over the details and work things backward to the source of the problem. It does the job, but takes a back seat once the details have been discovered.

Some while back I got pointed in the direction of another leak detection tool, Deleaker from Softanics, of which I hadn't heard at that point. It’s taken me a while to clear my desk sufficiently to check it out but I’m pleased to have done so, as it’s a very nice and helpful tool.

I should mention up front that this is a commercial tool, like FastMM5 (when not used with the GPL license) and unlike FastMM4, Delphi LeakCheck, MemCheck 1 and TCondom 2. It costs $99 for a home license and $399 for a single developer license.

Some key points about Deleaker:

  • It is not just a tool for EMBT development languages: it supports Delphi, C++Builder, Visual C++ and Qt Creator
  • It’s not just a memory leak detector, but also supports resource leak detection for a pleasing array of resource types
  • It is not just a library, but offers a full UI experience, either integrated into the IDE (RAD Studio, Visual Studio, Qt Creator) or standalone, or even controlled through a command-line utility for use in Continuous Integration setups
  • It supports Win32 and Win64 targets

If you and/or your development team happens to dabble in C++Builder or Visual C++ then this tool would be a common weapon to deploy against leaks of all sorts.

The list of entity types that can be tracked looking for leaks is impressive:

Wednesday, 12 February 2020

The Enter key and the OnKeyDown/OnKeyUp events on Android

A problem surfaced on Stack Overflow recently from a Delphi developer, Tom Byrnes, who discovered that on Android, the Enter (or Return) key no longer triggers the OnKeyDown and OnKeyUp events. This was unfortunate as Tom wanted to code to run in (one of) those handlers.

The problem had been reported as RSP-27496 but alas it had been closed at the time Tom was hunting for a solution (to my mind closed wrongly).

What to do?

Well, after some valiant fighting with the problem accompanied with the inevitable wailing and gnashing of teeth, Tom found a workaround of sorts. Setting the TEdit control's ReturnKeyType property Go, Search or Send allows the OnKeyDown event to fire for the Enter key. Good stuff! But not ideal....

I sent a note to a relevant party within EMBT and after reviewing the report it has since been re-opened. That's a start.

Tuesday, 11 February 2020

C++Builder's Android location sensor woes

There is an unfortunate problem with RAD Studio 10.3.3 for anyone using C++Builder building Android applications. However it has a quite straightforward resolution, so let's look at what the issue is.

If you make a new Multi-Device Application in C++Builder and build it, all will be well, of course. The basics work very nicely.

If you now drop a TLocationSensor component on the form and try to build now, the result will be different. Compilation goes fine. Linking looks like it is going fine.... until it fails with a rather unhelpful message:

[ldandroid Error] "ld" exited with code 1.

Let's look at how we can get more useful feedback from this rather opaque and somewhat 1990s error message and see how to resolve the underlying problem.

Rebuilding the Delphi & C++Builder Android Java files

Some while back I posted a command script (or batch file as we used to call them) that could be used by RAD Studio 10.3 users if they felt the need to change any of the few Java files underlying Delphi's (and C++Builder's) Android RTL and FireMonkey code.

The script would rebuild all the Java files into the required fmx.dex.jar and fmx.jar archives and copy them into the relevant RAD Studio installation folders to be used on subsequent builds.

When I tried to use the script with RAD Studio 10.3.3 of course it didn't work as things have changed, different files need to be involved in the process. I have updated the script now to work with RAD Studio 10.3.3 and thought I'd share it in case anyone else needs to do this.

An obvious question is: Why would anyone else want to rebuild the Java Android RTL files? Well this is normally a necessary step if you find an issue in the code as Embarcadero ships it and you want to try to fix it or enhance it. Indeed the previous post on rebuilding the 10.3 Java files was all about patching the Java code to get Android Intent support working.

If you have no interest in tweaking the Java code or fixing any issues you encounter in the Java code then you probably won't be needing this script.

If you do need the script, remember to take a backup of your original compiled archives before you proceed. These are found in:

  • C:\Program Files (x86)\Embarcadero\Studio\20.0\lib\android\debug\fmx.jar
  • C:\Program Files (x86)\Embarcadero\Studio\20.0\lib\android\debug\fmx.dex.jar
  • C:\Program Files (x86)\Embarcadero\Studio\20.0\lib\android\release\fmx.jar
  • C:\Program Files (x86)\Embarcadero\Studio\20.0\lib\android\release\fmx.dex.jar

The script needs to be run from an administrative command prompt and before you run it you should double-check the various paths set up in the environment variables at the start are all valid on your system.

Saturday, 8 December 2018

RAD Studio 10.3 Rio’s Android Intent support (or current lack thereof)

Sometimes when a new product is released there are a few ‘teething issues’. That certainly seems to be the case with RAD Studio 10.3 Rio. Both Delphi and C++Builder are hitting a few problems on various fronts. Now, it is true that internally in the product there has been a lot of change in the IDE, the VCL and FireMonkey, and perhaps it is therefore unsurprising a few slip-ups will have occurred.

It is, however, quite annoying when you fall foul of these slip-ups and have to wait for a fix….

The issue I want to address in this post is the breakage in the Android support for registering an interest in knowing about certain Intent objects received by the app. This is normally achieved by a call to MainActivity.registerIntentAction, as pseudo-documented here (when it was introduced in RAD Studio 10 Seattle) and here (in reference to a sample app) on Embarcadero's docwiki and illustrated here in my article on NFC usage.

This new Intent support worked nicely in RAD Studio 10 Seattle, 10.1 Berlin and 10.2 Tokyo. Not so in RAD Studio 10.3 Rio. You get a crash when trying to register a new Intent that you want to act upon.

Thursday, 22 November 2018

RAD Studio 10.3 Rio supports Android runtime permissions

RAD Studio 10.3 Rio has just been released for General Availability, as you’ll have doubtless learned from the spree of blog posts on the subject. This is a great new release with a lot of bug fixes and some nice updates to product behaviour and features.

One feature that seems to have not received its fair share of attention in the documentation is the support for the Android 6.0 (and later) runtime permissions model. This caused a bit of frustration earlier in the year when Google changed the Play Store submission rules so that from August 2018 new apps have to follow this new permissions model and from November 2018 app updates also new apps have to.

RAD Studio 10.3 enhances the basic Android support to ensure that Android apps built with Delphi or C++ now understand and can support this new model, which may require a bit of change to your application logic.

In essence, instead of all permissions being granted on application installation, so-called dangerous permissions now need to be requested at runtime where the user can grant or deny them as they see fit. Additionally the user can change their mind in the app settings and toggle the permissions at any time.

The Android RTL has been enhanced with a framework to support requesting permissions at runtime and being notified of the user’s decision, and potentially offering a little explanation for the need for the permission.

As mentioned the documentation for this framework falls a little short right now (at product launch), but hopefully will improve over time. To try and plug the gap I’ve written an article showing how the permission framework can be used, both in Delphi and in C++. If interested in learning more about the Android runtime permission framework introduced in RAD Studio 10.3 Rio, please follow one of these links:

Finally, while I have your attention on things Android, I would like to draw your attention to the Android-specific release notes for RAD Studio 10.3. You should read these to be sure of getting on with your first Android project with the new product release. It needs and uses a later Android SDK and NDK and you mat encounter some teething niggles on installation. These notes should help you!

Tuesday, 7 November 2017

CodeRage XII session files – Directly Using The Android API

My CodeRage XII session on Directly Using the Android API has been aired on the Internet. If you saw it I hope it came across reasonably well (interruptions notwithstanding) and might prove useful to you in your endeavours with Android.

As promised, the slides and samples are now available at this link. Do enjoy, now ˚◡˚   [ Update: the broken link has been fixed ]

Apologies for the interrupted video transmission during the conference. Rest assured that as soon as Jim can manage it, pretty much all the CodeRage videos will be made available for replay. As soon as mine is available I shall be updating this post with the link and also linking to it on my Conference Talks web page. You can see it at your leisure now here at Embarcadero Academy.

CodeRage XII session

A whole 5 years ago (!) I did a session for CodeRage 7 on accessing the Android API. This was not long after RAD Studio XE5 introduced support for developing Android applications, and Delphi’s Android support was in its first stage.

5 years on and CodeRage XII is starting today. I’ll be doing an updated talk on the same subject covering all that’s new in RAD Studio 10.2 at 3pm CST today, Tuesday 7th November 2017. I hope you can join me!

A full timetable of sessions is available in this PDF download in case you’re having trouble working out which sessions to attend.

Sad for me (due to working on-site meaning I won’t be able to catch them – alas they won’t be made available as replays!) but hopefully fabulous for many of you (if you can attend the sessions) is the inclusion in the list of speakers of a couple of legends in their areas:

These are well respected industry luminaries and Malcolm Groves, among others, has a lot to say about them.

Enjoy CodeRage XII!

Sunday, 29 October 2017

‘What if?’ scenario analysis in the CPU window

Last Tuesday, 24th October I did some sessions at EKON 21, one of which was on Creative Debugging Techniques. During the session there was a section where I was trying to demonstrate an idea or technique that happened to fully involve the CPU window. Unfortunately a series of finger fumbles on my part meant I couldn’t show what I wanted to show, albeit I think the point was made.

Anyway, I mentioned that maybe I’d write up that little snippet into a blog post, just to prove that it really does work as I suggested it does, and so here it is.

Tuesday, 17 October 2017

Remote debugger recalcitrance

My development machine in my main week day job does not have some custom hardware that a nearby test machine does. It doesn’t make sense to load up the development environment onto the test machine for various reasons, so I am a fairly irregular user of remote debugging against my Win32 application.

As it happens the client language is C++Builder (classic compiler), but I expect this issue to apply equally to Delphi (I’d be interested to know from anyone who can confirm one way or another).

Remote debugging works quite nicely via PAServer. It is certainly straightforward in comparison to the games we had to play some years back – PAServer seems to have simplified the setup quite nicely.

Granted, stepping is pretty slow, but then there’s quite a lot going on and a certain amount of information for PAServer retrieve from the remote debugger (rmtdbg250.exe) and then to send back to PAClient and to the IDE, so I can take that.

What gets my goat, though, is what happens when the program ends. Often I have to kill the application (Ctrl+F2, or Run, Program Reset), but often the application exits quite naturally.

More often than not I can’t make a change in the code and have F9 successfully compile and run up the app remotely again. I get this:

[PAClient Error] Error: E0009 Cannot create file "\\?\C:\Program Files (x86)\Embarcadero\PAServer\19.0\scratch-dir\some_subfolder\project_name\project_name.tds". The process cannot access the file because it is being used by another process

Monday, 16 October 2017

Project corruption bug

Long ago there was an issue with the RAD Studio IDE (Delphi and C++Builder both). It meant that when changing certain project options or switching build configurations, the (XML format) project file would get saved with an extra errant (empty) XML element in it, causing subsequent compilations to baulk, complaining about: ProjectExtensions appears multiple time in project. If you build from the command line the error looks like: [MSBuild Error] MSB4079 The <ProjectExtensions> element occurs more than once.

The extra line in the file, were you to open it in a text editor and take a look, will be rather like this:

    <ProjectExtensions />

If you peruse some of the entries in Embarcadero’s Quality Central portal, such as this, this or even this, then you’ll see that Embarcadero made some changes in XE6 that improved matters (done against Quality Central bug 109016, no longer accessible since QC went offline some while back, but in this list of XE6 fixes), but clearly has not dismissed the problem entirely. Various customers do continue to hit it, albeit not very reproducibly.

Tuesday, 22 November 2016

Debug logging in FireMonkey – CodeRage XI Lightning Talks

During CodeRage XI I had a couple of Lightning Talks broadcast on a subject I’ve been intending to write up for quite a long time, but haven’t quite managed to achieve: how to emit debug log messages on the various FireMonkey platforms.

I made a 10 minute video for Delphi and one for C++ looking at all the target platforms, Win32/Win64, OS X/macOS, Android and iOS, showing the logging options and then looking at how to view log output.

Unfortunately I got a bit caught up in some work and didn’t publicise this ahead of the conference, so I think not many people were aware of them.

Thursday, 23 June 2016

Live Templates (née Code Templates)

Over the years since Delphi 3 various people have written about aspects of Code Templates and Live Templates, but not particularly recently. I find Code Templates fabulously helpful and Live Templates add some real power into the mix.

About six or seven months ago (November 2015) I did a User Group talk on Live Templates and it seemed to provoke some reasonable interest. Since then I’ve been trying to find a suitable time window to sit down and write it all up. At last I have had a couple of days to gather my thoughts and get it all down on (metaphorical) paper.

For the benefit of those who haven’t considered creating Live Templates to help their productivity, or who have forgotten about the feature over time, please feel free to peruse Code Templates and Live Templates over on my web site.

Sunday, 3 January 2016

Some Delphi and C++Builder articles

My blog editor of choice is proving to be a little quisquous at the moment.

Historically I have used Windows LiveWriter, part of Windows Essentials (whose development stopped in 2012, but was still available here (web installer) and here (offline installer)). This worked well, but at some point over the summer it stopped working with the uprated authentication requirements of Google’s Blogger. Fortunately though, it has just been open-sourced and is now available as Open Live Writer here.

However while one issue I immediately hit with this new version has been fixed, I have still yet to successfully connect to my blog with Open Live Writer. Fingers crossed….

So until the initial set of issues are worked out I’ll post articles and link to them by short manually entered blog entries here.

This post is mostly to point at a short article I’ve put together that brings to the attention of those who are interested the easy means to lessen the size of your Windows application’s executable file.

You can find the article here: Trimming The Fat - Smaller Windows .exe Sizes With Delphi And C++Builder.

[Update 20150105: I've made some changes to the advice in the Trim the Fat article (clearly marked) after some input came through from a helpful reader.]

Before signing off I want to mention a couple of other posts that recently caught my eye:

Daniele Spinetti has very recently worked out the solution to a bug he encountered with Android background services in Delphi 10 Seattle, which meant that the TLocationSensor component doesn’t function when used in an Android service data module. The problem has been identified and described in his (very) recent post. This will be a useful addition to those trying to use Android services to accompany Jim McKeeth’s offerings:

Daniele also has a post showing how to use AdMob insterstitial adverts in Android apps as an alternative to regular banner ads.

Some posts from Chee Wee also stood out as interesting:

Happy New Year!

Tuesday, 31 December 2013

Catching up on happenings in the Delphi world

When I’m head-down in a ‘long hours’ contract I tend to miss quite a bit of Delphi-oriented news. Once in a while I look up and I find a whole host of interesting posts around the blog-world and this has been the case over this seasonal break.

I’ve been browsing around seeing what’s new and have collated the following list of stuff I found interesting. Anyone else who hasn’t been keeping up-to-date on news of late might possibly also find some stuff of interest in the list.

Happy New Year!

Thursday, 26 September 2013

Nostalgia. Is it just a thing of the past?

I was put onto this treasure trove of old scanned manuals the other day: http://bitsavers.informatik.uni-stuttgart.de/pdf/borland. It contains a huge directory hierarchy of PDF scans of old product manuals from all sorts of vendors. And that’s scans of the whole manuals, not just the front covers.

Want to brush up on your Turbo Pascal 7 language? Or review the details of the Turbo Pascal Graphix Toolbox (all the Turbo Pascal manuals are here, while Turbo C manuals are here and Borland C++ manuals are here)? Or recollect the specific of Sidekick Plus (Sidekick manuals are here)? Or be reminded how Turbo Prolog worked (Turbo Prolog manuals are here)?

Turbo Pascal Reference Manual

All this and more are there as PDFs. And not just old Borland manuals. Oh no, browse up the directory tree and you can find oodles of stuff on say, the Apple Lisa (Apple’s manuals start here and the Lisa manuals are here).

What a great resource for those who like to look back from time to time :o)

ObjectVision Reerence Manual

Take a browse through and see how many product manuals you’ve forgotten all about.

Turbo C User's Guide

Ahhh, product manuals. Those were the days!

Oh, and while on the subject of manuals, back in the day the Borland documentation team did like to have a bit of fun in their work. The Delphi 1 manuals contained a couple of Easter Eggs.

Thursday, 19 September 2013

Where has all the colour gone?

Once upon a time there was colour and interest a-plenty in development tool splash screens. Well, this was certainly the case with Delphi and C++Builder anyway.

And then corporate America took over and things dulled down with an unmistakable business-like tone.

Take a look through the progression of splash screen I have here and see if nostalgia strikes.

1997: Delphi 3

Delphi 3

1998: C++Builder 3

BCB3Splash

1998: Delphi 4

Delphi4Splash

1999: C++Builder 4

BCB4Splash

1999: Delphi 5

Delphi5Splash

2000: C++Builder 5

BCB5Splash

2000: JBuilder 4

JBuilder4

2001: Delphi 6

Delphi6Splash

2002: Delphi 7

Delphi7Splash

2004: Delphi 2005

Delphi2005

2005: Delphi 2006

Delphi2006

2007: Delphi 2007

Delphi2007

2007: C++Builder 2007

CBuilder2007

2008: Delphi 2009

Delphi2009

2008: C++Builder 2009

BCB2009

2009: Delphi 2010

Delphi2010

2010: Delphi XE

DelphiXE

2011: Delphi/RAD Studio XE2

DelphiXE2

2012: Delphi/RAD Studio XE3

DelphiXE3

2013 – Delphi XE4

DelphiXE4

2013 – Delphi XE5

DelphiXE5

Tuesday, 4 June 2013

‘Dynamic’ Delphi/C++ samples on SourceForge via Subversion

Many of you will have already bumped into this information, but I’m posting it for the benefit of those who haven’t come across it.

In much the same way as how the static RAD Studio online documentation is complemented by updatable and updated web-based documentation at http://docwiki.embarcadero.com, the sample applications supplied with RAD Studio are also updated over time and available via an online Subversion repository hosted at SourceForge.

The RAD Studio Demo Code Web Site is at http://radstudiodemos.sourceforge.net and the SourceForge project page is http://sourceforge.net/projects/radstudiodemos. To pull down the demos you can use your favourite Subversion client and use the checkout functionality.

With regard to Subversion clients I like using TortoiseSVN from within Windows Explorer, although there is also a TortoiseSVN plug-in for the RAD Studio IDE. Of course if you use Delphi XE or later you can perhaps more sensibly just use the built-in RAD Studio IDE Subversion support.

Suitable Subversion repository URLs for the RAD Studio demo projects include:

From time to time you can again use your Subversion client to update the demos to take advantage of any changes made in the online repository. It’s good to be kept up to date!

Above I touched on the online up-to-date documentation. For completeness I should mention that the docwiki is available from Delphi’s Help menu (RAD Studio Docwiki) and I should also offer up this list of entry pages to the online help systems:

Finally, it’s always nice to get a refresher on what’s been added in recent product releases, so do stop by the What Was New In Past Releases page on the docwiki.

Friday, 8 March 2013

More on FireDAC

I’ve yet to pull down and start playing with FireDAC, but it was featured in an Embarcadero event in London yesterday (Thursday). Some points with it were clarified by DavidI, which I thought were quite enlightening:

  • As well as Embarcadero acquiring the intellectual property and all that goes with AnyDAC from DASoft, the original AnyDAC developer, Dmitriy Arefief, is now on a very long-term contract with Embarcadero to keep the development of the product moving forwards.
  • FireDAC is intended as the replacement for dbExpress (DBX). Ultimately dbExpress will be deprecated, but doubtless will still be available for many versions to come (after all, WebSnap is still shipped in the box and hasn’t been focused on for a long time).
  • DataSnap currently relies on dbExpress and Indy. Over time DataSnap will be worked on to make use of FireDAC instead of DBX.
  • FireDAC was attractive to Embarcadero as it covers a much wider range of databases when compared with DBX: Oracle, DB2, SQL Server, InterBase/Firebird, PostgreSQL, MySQL, SQLite, Sybase SQL Anywhere, Advantage DB and Access, along with support for ODBC and dbExpress drivers. It also has a number of useful features, including a performance monitor (ADMonitor), a database explorer (ADExplorer) and a migration tool to convert BDE apps to use FireDAC components.

Additionally, I see in the FireDAC FAQ that if you are not yet an XE3 user you can still make use of FireDAC in older IDEs by installing it with a particular command-line parameter. According to Marco Cantù the command-line for installation into XE2 is /IDE:DXE2. However I’m not sure how many versions back are supported.

[ Edit: there is now a support article showing how to install into any IDE using the installer’s /showide command-line switch ]

Another change with the AnyDAC –> FireDAC transition is the dropping of support for Lazarus/Free Pascal Compiler, so Linux targeting is now out of the question. If you’re a Delphi customer, this is unlikely to ruffle your feathers, but I guess Lazarus users might be more rightfully irked.