Dec 292017

Today I had a rather annoying problem with Delphi XE2. I only wanted to change the caption of a TListView column using the Columns Editor (right click -> Columns Editor). The IDE crashed on me with an Access Violation. So, I thought I had broken it again (things like this happen when you are developing IDE plugins) and uninstalled GExperts. After a restart I tried it again and got the same Access Violation, proving at least that GExperts was not the culprit.

So, which other IDE plugins were installed? To find out, I opened the Help -> About dialog, which immediately crashed on me with an Access Violation. It happened while it was drawing the list of Installed Products.

Next I tried to debug Delphi with itself, loading the GExperts sources. The problem at least was reproducible and the call stack told me the crash was in TCustomListView.CNNotify. That unfortunately wasn’t very helpful apart from telling me that it had something to do with custom drawing (which was deeper in the call stack) of a TListView, which was what both crashes shared: The About Dialog as well as the Columns Editor both use TListView and apparently do custom drawing.

So, I removed all experts that I had installed …

… and tried it again. At first, it seemed to work, I could open the About Dialog and nothing bad happened. Then I opened the project I was trying to change, called the Columns Editor and – boom – got the Access Violation.

I restarted the IDE again and looked into the About Dialog. There were only the Embarcadero Quality Insight and the JEDI Visual Component Library left. No crash occurred. I reloaded the project, opened the About Dialog again and got the now familiar Access Violation. WTF? Could it be the JVCL?

I renamed the JvCore160.bpl package that all jvcl packages load. And tried again. I got lots of error messages when I started the IDE and again when I opened my project, but I could successfully open the About Dialog.

So, if it really is the JVCL, why did the Access Violation only occur when my project was loaded?

I made the JvCore160.bpl package available again, restarted the IDE, but this time created a new VCL project and added a JVCL component to it. I opened the About Dialog and got the AV. I guess that proved the point.

That was when I remembered reading about Delphi 2005 (and later) loading packages on demand instead of on startup. This explains why the AV happens only after a JVCL component was used in a project: Because otherwise the packages simply were not loaded at all.

Unfortunately that didn’t help much, because my project needs the JVCL (in particular the TJvFilenameEdit component), so I could not simply uninstall it. Since I had not heard about this problem, I guess it isn’t wide spread. One possibility is that I have produced it myself by sticking with an older JCL/JVCL source code and simply patching it to make it compile with Delphi XE2 instead of keeping up with the latest version (The reason for that is that I don’t like the hassle with Git, so I stopped following the JEDI projects when the sources were moved from SourceForge to GitHub.)

I went to GitHub, downloaded the latest ZIP files from all three projects, put everything together and installed JCL and JVCL to Delphi XE2 (the JCL installer dialog looks intimidating if you have got 18 versions of Delphi installed). I then had to remove the directories from the library paths again and compile several of my packages that need the JCL or JVCL+JCL, which required me to make some small changes to my code. But it took only about half an hour, which is nothing compared to the several hours I had already wasted trying to find out what made Delphi XE2 crash.

I loaded the dreaded project again, and everything worked fine. I could finally change the List View captions which was all I wanted to do to start with.

Isn’t it great when everything just works?

Sorry, the comment form is closed at this time.

%d bloggers like this: