Today I stumbled over the adt field types in Delphi Datasets. We use custom client datasets to bind objects to datasets in our views. With that dataset and our custom derivation of TDbGrid
and enabled FastMM4 full debug mode we get an access violation with the following stack trace:
System.Generics.Collections.TListHelper.DoIndexOfFwd4((kein Wert))
System.Classes.TComponent.FreeNotification($7F961CE0)
Vcl.DBGrids.TColumn.SetField($7F971700)
Vcl.DBGrids.TColumn.GetField
Vcl.DBGrids.TCustomDBGrid.Notification($7F971220,???)
System.Classes.TComponent.RemoveFreeNotifications
System.Classes.TComponent.Destroy
Data.DB.TField.Destroy
System.TObject.Free
Data.DB.TFields.ClearBase(True)
Data.DB.TFields.ClearAutomatic`
Data.DB.TDataSet.DestroyFields
Datasnap.DBClient.TCustomClientDataSet.InternalClose
Data.DB.TDataSet.CloseCursor
Datasnap.DBClient.TCustomClientDataSet.CloseCursor
Data.DB.TDataSet.SetActive(???)
After some debugging fun, i found out that the internal FieldList
of the Dataset contains a already destroyed field. After doing some more reasearch, I found out that disabling property
DataSet.ObjectView
disables the internal FieldList
and the access violation goes away.
As we don't use ADT field types, I suspect disabling it does no harm, but one never knows.
Background
I've had already a lot of problems with TDataSet
and TDbGrid
, starting with the inherent problems of the flickering scollbar in the grid and ending in corrupt BCD-Parameters for oracle databases. We updated from XE3 to DX10, the access violation did not occur before.
- I can not post the code of our custom dataset / custom grid
- we are freeing the dataset before the grid