Access violation while closing form with a TDBAdvGrid

In some of the forms in my application I get an access violation on closing.
The debugger breaks on line 7017 in DBAdvGrid.pas.
The code is referring to FDataLink that is not defined anymore at this point.

I solved this by adding 2 lines at the start of the procedure:

procedure TDBAdvGrid.UpdateRowCount;
  OldRowCount, NewRowCount: Integer;
  ShouldRepaint, OldDoNotCountRow, OldValue, OldInternalCall, OldSel, ReCountedRows: boolean;
  OldRow, br: integer;
  if csLoading in ComponentState then
// Added next 2 lines to avoid Access violation on closing form
  if csDestroying in ComponentState then

Hopefully you can include this in your next update.

With regards,

Peet Terluin

We can certainly include this in the next update.
It would be better though to be able to reproduce this so we can understand what is happening.

It would be better though to be able to reproduce this so we can understand what is happening.

I understand that. However, I haven't been able to pinpoint the cause of this problem. And at the moment I have little spare time to construct a working demo that reproduces this behaviour. Because the counting of rows on closing a form does not seem very useful to me I just went with this quick fix.

The application in which this occurs uses a MySQL database an with that I use DB-components of Devart/MyDAC. A simple copy of the application would not be enough to get a demo that also compiles and runs on your systems.

If you decide not to include my suggested patch or another solution (if you accidentilly do find the cause...) it is no problem, i'll just re-apply my patch if neccesary.

with regards,

Peet Terluin

No worries, we will apply the patch, since it is harmless.
It is just that understanding how this got triggered would be even better.
So, let us know if you might see how to reproduce it in the future.

1 Like