Jump to content
Sign in to follow this  
Jacek Laskowski

FireDAC and AV in TFDDatSView.RemRef()

Recommended Posts

I have a strange problem with FireDAC (Delphi 10.3.2)


I create TFDMemTable dynamically, then I create its structure and index on base key (by memTable.Indexes.Add()).
Next, I import data from JSON file (saved previously by TFDQuery object):

 

memTable.LoadFromStream(x, sfJSON);

 

AV is raised in this FD code:

 

procedure TFDDatSView.RemRef;
begin
  FRefs.RemRef;
end;

And on this import I get access violation in FireDAC code, because internal TFDDatSView field is nil (see attached screenshot)!

 

When I remove the creation of the index there is no error. But I can't do it, because it's part of a big, generic mechanism and it's needed.

 

The index is created when MemTable is in dsInactive mode, can it be the cause?

I also noticed that when I do Open/Close this MemTable, there is no error either.


What is the cause and how to avoid it without performing spells (like close/open)?

 

vps_2020.03.12_02.png

Edited by Jacek Laskowski

Share this post


Link to post

OK, the problem is not in FireDAC, but in the code associated with Spring4D.

Injected interface for reasons I don't know yet reduces the reference counter to zero and is released, and with it FD objects.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×