odd D8/VCL.NET/IDE related problem - system.nullreferenceexception in Borland.VCL.DBTables
From: Robert Toeplitz (bobtoeplitz_at_freemail.hu)
Date: Fri, 7 May 2004 18:58:48 +0200
migrating from a Delphi 6 VCL application to a VCL.NET application I
bumped into a weird error, which was kind of hard to trace back and found it
impossible to resolve so hereby I turn to you all.
After some debugging and tinkering I could finally break down the problem to
the following scenario. This scenario mimicks a minimal subset of my future
VCL.NET migrated application's behaviour:
- Create a new VCL.NET forms application.
- On the default Form1 lay a TDatabase component and two TButton components.
For this example let's name them Database1, OpenButton and CloseButton. The
buttons' onclick events should do no more than <Database1.Open> and
<Database1.Close> respectively. Database1 should point to a living database
source, altho the underlying database-type is totally irrelevant (have
tested with local postgresql, remote postgresql, dbase and excel
datasource -- all produced the same error).
- Put a TDatasource and a TTable component on the form too. TDatasource
pointing to TTable and TTable pointing to Database1. Pick any of your
database's tables for the TTable.
- Given just these components I've described, compile and run the
application. Everything works just fine. Clicking the buttons in any order,
closing the form at any time and doing these activities in any combination
should not bring up any error.
- Now comes the oddness. What makes things all messed up is putting a
TDBEdit component on the form. It doesn't even have to point the
TDatasource! Compiling and running the application is still OK but if I open
the database and close the form without explicitly choosing to close the
database before, it creates a System.NullReferenceException. I found out
that the exception is thrown in Borland.VCL.DBTables' finalize section when
calling FreeTimer. The guilty party is FreeTimer's <if Assigned(DBScreen)
then DBScreen.Cursor := dcrDefault;> line.
Agan. Opening the Form then opening the database with OpenButton then
closing it with CloseButton and then closing the form still works fine. But
even putting Database1.Close; in the form's onClose or onCloseQuery event
methods won't even help.
Even more weird is that removing the TDBEdit from the form leaves things as
messed up as they were.
The nullpointerexception is not thrown when doing the same actions outside
the IDE, but during development it is kind of annoying because any time I'm
not quick enough to stop execution before the exception is thrown, the IDE
start's throwing arbitrary exceptions at different times which leads to the
necessity of restarting it.
I've tested this behaviour on 2 different computers (one of them had nothing
else installed just delphi 8 and it's prerequisites) each with Delphi 8
update #2 and on a third one, which didn't have the updates just Delphi 8.
All three tests represented the exact same bug.
Has anybody bumped into the same problem or anything that could be related
to it? Does anybody have a fix or workaround for it?
I couldn't find any.
Thanks in advance,