Experimental GExperts feature: Automatically close Messages window

 Delphi, GExperts  Comments Off on Experimental GExperts feature: Automatically close Messages window
Jul 012018
 

You might have become used to it, but probably every Delphi developer has at one time wondered why the Messages window is still visible (and takes up valuable screen real estate) even if it is empty. And even worse, if you close it manually, it automatically comes back when you compile your project.

I too, had become used to it, but got reminded of this nuisance by a recent post from Graeme Geldenhuys on Google+:

How to auto close Message View window on successful compilation.
This was asked for in Delphi 7, but it seems with Delphi XE3 (what I’m using) it’s still not possible. Anybody know of a 3rd party add-in or hidden Delphi setting that will close the Message View after a successful compilation?

If I save my “desktop environment” while the Message View window is closed, then compile it doesn’t display the Message View – if no errors occurred. If a error occurs, then the Message View automatically appears. After I fixed the compilation error and recompile, the Message View stays there and doesn’t close. At this point I want it to close automatically. It is so damn annoying. I need all the screen (editor) space I can get, and the always visible Message View is taking up vital space.

Any known solution for this? Once again, Lazarus IDE does this perfectly.

As far as I know, there is no solution, neither in the Delphi IDE itself nor in any plugin I am aware of. (Update: There actually is one) Until today that is: I have just committed a change to the GExperts repository with the following description:

new IDE enhancement: Automatically close message window (if no errors, warnings or hints)

It is, like most IDE enhancements in GExperts, a hack. It works by hooking the Progress window and when it closes, checks whether there were any hints, warnings or errors. If there are none, it starts a timer that will wait for 1000 ms and then search and close the Messages window.

It works for me, your mileage may vary, of course. If you want to test it, for now you have to compile your own GExperts DLL. Don’t forget to actually enable that option on the IDE page of the configuration dialog!

Some statistics about GExperts downloads

 Delphi, GExperts  Comments Off on Some statistics about GExperts downloads
Jun 242018
 

I always wanted to know how many people use my experimental version of GExperts but never came around to actually evaluate the download counts. Today I finally did it. In total there were 9092 file downloads from downloads.dummzeuch.de/GExperts. Since in 2016-05-07 I switched from ZIP files containing all DLLs to installers for each Delphi version it is a bit difficult to know how many downloads for which version there were, so I evaluated the ZIP files and installers separately.

The ZIP files had 1663 downloads where the three most popular ones were the releases from:

  • 2016-02-15 (388 downloads)
  • 2015-04-11 (277 downloads)
  • 2015-09-06 (258 downloads)

There is much more information to be gained from the 7429 installer downloads:

The most popular Unicode-Delphi versions seem to be

  • Delphi 10.1 (5366 downloads)
  • Delphi 10.2 (416 downloads)
  • Delphi 10 (377 downloads)
  • Delphi XE7 (123 downloads)

The pre-Unicode versions in descending popularity are:

  • Delphi 2007 (218 downloads)
  • Delphi 7 (209 downloads)
  • Delphi 2006 (55 downloads)
  • Delphi 6 (46 downloads)
  • Delphi 2005 (18 downloads)

The most popular releases in descending order are:

  • 2016-10-03 (1497 downloads)
  • 2016-06-05 (1488 downloads)
  • 2017-03-19 (1349 downloads)
  • 2011-01-15 (1255 downloads)

All others had less than 500 downloads.

The downloads for the most recent releases are:

  • 2018-06-03 228 downloads
  • 2018-03-31 133 downloads
  • 2017-04-01 256 downloads
  • 2017-03-19 1349 downloads

I think it’s a bit worrying that the last release with more than 1000 downloads is more than a year old.

These statistics can of course not count those people who rather than using an installer just check out the sources and compile their own DLLs, but I don’t think there are that many who do that.

Also, there are of course the downloads from SourceForge which still remain popular even though the latest release there is my experimental release from 2017-03-19. There have been 1292 downloads from SourceForge in 2018-06 to date and about 2000 monthly for the last few months. The all time high peak was in 2012-03 with more than 100000 downloads (I’m not sure that this is correct though, it’s so much higher than the all time average.).

My conclusion is that I probably couldn’t make a living from working on GExperts even if everyone who downloads it did actually donate the suggested 50 Euros per year which is by far not the case.

GExperts 1.3.10 experimental twm 2018-06-03 released

 Delphi, GExperts  Comments Off on GExperts 1.3.10 experimental twm 2018-06-03 released
Jun 032018
 

Given that the last Delphi release was more than a year ago and that I am about to go on vacation so I won’t be able to download and install a new version I would expect a new Delphi release pretty soon. On the other hand this time I actually managed to extend “my” subscription on time so in theory I could download the new version immediately when it becomes available, so the release might still be some time off.
(Greetings from Mr. Murphy)

Anyway, I thought it to be the right time to make a new GExperts release. I even managed to update the version number to 1.3.10 in the executables as well as in the installers and update a few of the auxiliary files.

I have created installers for all supported Delphi versions and I even tested them a bit on some fresh Delphi installations. They do work! How amazing is that?

New features include:

There were also several bug fixes including 3 Unicode issues.

I am pretty sure this new release is more stable than the previous one.

But anyway:

Please be aware that I mostly work with Delphi 2007, so this version can be regarded as tested quite well, followed by Delphi XE2. The others are only known to compile and new features are usually tested superficially with all versions. This is particularly true for Delphi 6/7 and 2005/2006.

Head over to the Experimental GExperts page to download the latest release it.

TThread is not a normal class

 Delphi, GExperts  Comments Off on TThread is not a normal class
Apr 222018
 

In Delphi, threads have traditionally been implemented as classes descending from TThread. While there have been quite a few improvements to multithreading, TThread is still the most compatible way. But TThread is not a normal class.

In a normal class, the constructor and destructor usually look like this:

constructor TSomeClass.Create;
begin
  inherited;
  FSomeList := TStringList.Create;
end;

destructor TSomeClass.Destroy;
begin
  FreeAndNil(FSomeList);
  inherited;
end;

In the constructor, we first call inherited and afterwards add code to initialize additional fields of the object. In the destructor we first free any fields of the object and only then call inherited for the ancestor class to free its resources.

Now, TThread is peculiar because its constructor and destructor are usually executed in the program’s main thread, while its Execute method is executed in a different thread. But, when is that thread started? It’s started when you call the inherited constructor. So any initialization that thread needs must be done before calling inherited!

Edit: Several people have pointed out that my claim is somewhat “outdated”, where “outdated” means that since Delphi 6 the thread is started in the AfterConstruction method rather than in Create. In Delphi 5 it was the last command in TThread.Create (here is a probably not authorized copy of that code, search for “Delphi5Thread” on the page).

What I wrote about the destructor is still true though.

constructor TMyThread.Create;
begin
  FSomeList := TStringList.Create;
  inherited;
end;

Otherwise the field FSomeList might not have been initialized when the thread tries to access it.

Similar, if the thread is still running, you must be sure that all the resources it requires are available until it has stopped. So, the first thing would be to tell the thread to terminate, wait for it to actually do that and only then destroy it.

MyThread := TMyThread.Create;
// do something else while the thread does its thing
// ...
// now tell it to terminate (this is standard way of doing that
// but it might not be the best)
MyThread.Terminate;
// and destroy it
FreeAndNil(MyThread);

But that’s only half of it. The destructor must also take care not to destroy anything the thread still needs:

destructor TMyThread.Destroy;
begin
  // first, wait for the thread to terminate
  // (the inherited destructor calls WaitFor)
  inherited;
  // now the thread has definitely terminated, so we can free the resources
  FreeAndNil(FSomeList);
end;

Beware: These are just the simplest precautions to take when programming with multiple threads. As they say: "Creating threads is easy but multithreading is hard." If you can, use a library that does the ground work for you.

Why do I blog about this? I just fixed a few Access Violations in GExperts that were caused by TThread objects implemented the wrong way. (I have no idea who did that, it’s quite possible that I am myself to blame for that.)

GExperts Usage Statistics

 Delphi, GExperts  Comments Off on GExperts Usage Statistics
Mar 302018
 

Have you ever wondered which functions of GExperts you have used the most? Or how often at all? How much time it has saved you?

Now you can find out: I just added Usage Statistics to GExperts which tells you exactly how often you have called each of the experts, in the current session and also in total (data between sessions is saved in the registry). Currently it can be accessed via a button in the Configuration dialog, but I am not sure yet where to put it.

So far, it has told me nothing new: My most used functions are, in descending order:

But this is just after a few minutes of actually using GExperts after I have added the statistics, so there might still be some surprises. I am wondering about the Code Proofreader for example.

I plan to do a new release shortly (oh my, the last one is over a year old!), maybe even during the Easter holidays, but don’t hold your breath. In the meantime, you can simply compile your own GExperts dll.

Fixing the Delphi 10.2.2 February 2018 Patch

 Delphi, GExperts  Comments Off on Fixing the Delphi 10.2.2 February 2018 Patch
Feb 172018
 

UPDATE: The problem was that I was using Delphi 10.2.2 build 1978. Apparently I have missed an update in December 2017 to build 2004. I have downloaded and installed the new version, and now the patch worked fine.

I hereby apologize for being stupid, because it clearly says in the description:

This patch for RAD Studio 10.2.2 (build 2004 — it won’t work on build 1978) resolves some compatibility issues in the RTL and fixes a problem with Android animations. It is designed to be installed only on top of an existing RAD Studio 10.2.2 Tokyo installation.

(emphasis mine)

I was so sure to be running the latest version that I didn’t even check. Sorry about causing so much fuss.

I’ll leave the rest of the blog post unchanged just in case anybody is googling for some of the key words and to remind me to check first and complain later.

After I reported the problem with the Delphi 10.2.2 February 2018 Patch, Embarcadero first removed the download and has now released a new installer. Unfortunately this new patch might have solved some other problems, but it didn’t solve mine. I did a complete uninstall of Delphi 10.2.2 (I even removed all directories and files that the uninstall left behind) and a new installation from my DVD followed by applying the new patch. I could still not compile GExperts and the simple test program I described in the steps for the bug report did not compile either. (Guess what: Embarcadero apparently never actually tried to reproduce my problem, but the ticket was closed anyway.). I don’t know what exactly they think they fixed, but they didn’t fix the problem I reported which is:

RAD Studio 10.2.2 Tokyo February 2018 Patch breaks “Link with rutime packages”

  1. Create a new VCL project
  2. Open project options
  3. Select Packages -> Runtime Packages
  4. Set “Link with runtime packages” to true
  5. Close dialog with OK
  6. Compile the project
  7. -> Error

Today I tried to find out what the problem was and how to fix it. It turned out to be actually quite simple:

They updated the packages rtl.bpl and fmx.bpl together with their corresponding .dcp files. Since the .dcp files contain some versioning information the packages that use these packages (e.g. vcl.bpl which uses rtl.bpl) were no longer compatible with the new packages and the compiler complained about this.

So, the fix for this would be to recompile all the packages depending on rtl.bpl and fmx.bpl, but since I don’t have all the sources required for that, I couldn’t do that (but Embarcadero should).

What I did instead was replacing the .dcp files in libs\win32\debug and libs\win32\release with the .bak files that the Patch created. Afterwards, GExperts compiled again. And since probably the interface of the bpl files didn’t change, I don’t expect any problems. But of course, I can’t guarantee this. So, if you follow my example, you might still run into problems and, No, I won’t fix your computer. 😉

GExperts Bugfixes

 GExperts  Comments Off on GExperts Bugfixes
Dec 302017
 

The Unicode issues in GExperts just don’t end. Today I fixed three of them:

procedure bla;
begin
  SomeVar := 3245;
  // german description with some äöüß to SomeVar
  SomeVar := 123;

  SomeQuery.FieldByName('GermanWordWithäöüß').AsString := 'some value';
end;

(Yes, I know, this doesn’t compile.)

  • Move the cursor to the first occurrence of SomeVar and press Ctrl+Alt+Down. The cursor jumps to the middle of the next Occurrence of SomeVar instead of the start of the identifier.
  • Move the cursor to the opening parenthesis after FieldByName and press Ctrl+Alt+Right. The cursor moves to somewhere in AsString rather than the closing parenthesis.
  • Move the cursor to the closing parenthesis and press Ctrl+Alt+Left. You get the error that AsString is not a valid delimiter

They were caused by the two byte UTF-8 characters in the respective lines which threw off the column index.

And if that wasn’t enough I also fixed some bugs in the Grep history list which could cause an Access Violation, infinite loop or wrong check marks in the Open dialog.

All these were reported by Konstantin Tkachenko who also included some patches which fixed them. Unfortunately he could only test them in Delphi 2010 so they worked for Delphi 2007+ but not for Delphi 6 and 7. They were valuable nonetheless. Thanks Konstantin!

Also, Achim Kalwa, who already contributed quite a few patches to GExperts, sent me some more this week:

  • Remove the ugly “(S+C+x)” suffixes in the Project Options dialog and replace them with a hint.
  • Sort the component names by tab order in the Copy Component Names expert.
  • Shortcuts for Add/Remove/Default buttons in the Editor Popup menu configuration dialog as well as sorting the list of experts alphabetically.

I’m no longer accepting GExperts donations via Flattr

 GExperts  Comments Off on I’m no longer accepting GExperts donations via Flattr
Oct 212017
 

Flattr have changed their terms an conditions. Since I haven’t received a single cent via Flattr, I really can’t be bothered what exactly they have changed and whether that’s good or bad for me personally. So I have closed that account for good. That leaves only PayPal, if you want to make a donation to GExperts. Sorry, if that’s an inconvenience. And please remember that I’d prefer you to contribute to GExperts in one of the other means described on that page than money.

Enhancements to GExperts Grep

 GExperts  Comments Off on Enhancements to GExperts Grep
Oct 142017
 

Jeroen has submitted two enhancements to GExperts:

Thanks!

I am still working on the refactoring for the IDE form enhancements, but progress is slow, so the next release will probably take a while.

Some documentation on the internals of GExperts

 Delphi, GExperts  Comments Off on Some documentation on the internals of GExperts
Aug 202017
 

I have started to write some documentation on the internal workings of GExperts. For now, it covers only a very small part of the IDE form enhancements that GExperts provides. It is meant mostly for myself to get an overview of that part of the tool which has grown too large to understand at a single glance. But it might also help if somebody wants to contribute to that part.