You are not logged in.
In some cases there is AV in StrLen (StrLenSSE2) when it's called with invalid pointer (usually it's $1).
That occures when StrLen is called from TSQLTable.GetString (which is called from ExpandAsString),
That pointer is returned with U := Get(Row,Field).
This happens all the time (to me at least), from debugger but I don't know how to create a test case since in runtime it happens only sometimes.
Here are more details, data is created with TSQLRecord.CreateAndFillPrepare (few rows is returned), and those data is shown with TSQLTableToGrid and draw grid.
When new filter is applied (that doesn't return records) to same SQLRecord with FillPrepare, it happens that somehow (I don't understand how exactly) draw grid paint cycle is invoked before FillPrepare finishes which puts data in inconsistent state so this AV occures.
This could be fixed if TSQLTableToGrid doesn't invoke paint cycle or if it's unlinked from SQLTable while table is being updated (in FillPrepare). AFAICS this isn't possible from within TSQLTableToGrid, i can only nil OnDrawCell event and restore it later, but I think some new method (like TDataSet.DisableControls) should be introduced.
Also TSQLTableToGrid.Destroy, tries to release associated SQLTable
with FreeAndNil(fTable), but it shouldn't do so since it doesn't necessarily own that table.
Offline
A lot of things here... difficult to find out all the items...
If you disable StrLenSSE2 use, does it work without A/V?
I'm not sure it is due to StrLenSSE2, but probably because your TSQLTableJSON instance is released, in your code, before use in TSQLTableToGrid.
If you use CreateAndFillPrepare, the internal TSQLTableJSON is owned by the TSQLRecord instance, so I guess this is why your A/V occurs later on in the grid.
You should use a dedicated TSQLTableJSON instance, or plain JSON, as in the samples.
Offline
Thanks for the help.
> If you disable StrLenSSE2 use, does it work without A/V?
No, it fails in UnCamelCase then.
> I'm not sure it is due to StrLenSSE2, but probably because your TSQLTableJSON instance is released, in your code,
> before use in TSQLTableToGrid.
You're right, within FillPrepare, FillClose is called that released TSQLTable.
> If you use CreateAndFillPrepare, the internal TSQLTableJSON is owned by the TSQLRecord instance,
> so I guess this is why your A/V occurs later on in the grid.
> You should use a dedicated TSQLTableJSON instance, or plain JSON, as in the samples.
So I cannot use SQLRecord.FillTable with TSQLTableToGrid? I have to create a separate TSQLTableJSON instance and then copy values from SQLRecord.FillTable to it?
What is the prefered/fastest way to copy all records from SQLRecord.FillTable to TSQLTableJSON?
Can you please update documentation for TSQLTableToGrid, and emphasize that it must be used with a dedicated TSQLTable/TSQLTableJSON instance.
Also I would suggest to include TSQLTableToGrid usage in pair with SQLRecord.CreateAndFillPrepare or FillPrepare, right now none of samples handle directly displaying data from TSQLRecord.
Last edited by igors233 (2016-05-03 16:48:02)
Offline