Access Violation in TCustomAureliusDataset.ClearInternalList

as already discussed in Access Violation when closing an Aurelius Dataset

Is it possible, that
TBaseAureliusDataset.InternalSetSourceList could do this: (or an overwritten Method of TCustomAureliusDataset)

if (FInternalList.Count > 0) and (FInternalList[0] is TCriteriaResult)  then
  FIsCritResultList := True;

while TCustomAureliusDataset.ClearInternalList would just use this boolean?

if FIsCritResultList then
  FInternalList.OwnsObjects := true;

I think in TBaseAureliusDataset.InternalSetSourceList you are pretty sure, that your first object exists and is not freed.

We are using FastMM. While debugging, freed objects will be replaced by TFastMMFreedObject... So this exception does not appear in debug and is realy hard to find in complex scenarios.

I don't think this is feasible. This will break backward compatibility and existing applications. Nothing prevents you from setting OwnsObjects yourself for the list.

Maybe you could prevent this by checking if FInternalList.OwnsObjects is already true?

  if not FInternalList.OwnsObjects 
    and (FInternalList.Count > 0) 
    and (FInternalList[0] is TCriteriaResult) then
    FInternalList.OwnsObjects := true;
  try
    FInternalList.Clear;
  finally
    FInternalList.OwnsObjects := false;
  end;

So, if I would set OwnsObjects to my List, it does not need to be checked anymore and I do not have to release my list after releasing my dataset.

But it would not help for Objects managed by objectmanager.

That doesn't change much, backward compatibility is still breaking. And it's not a good design, it's up to the user to decide if the list should own its objects or now, the dataset shouldn't force that.

Ok, so I have to make sure, that objects used in a dataset are released after closing (or releasing) dataset.

I think I would implement a TObjectMessage for TObjectManager and assign used objectmanager to an own Field in our TAureliusDataset descendant, so that posts will not be committed immediately, as it would happen if I would use existing property.

With this message I could implement assertions finding this easier.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.