QuickLib icon indicating copy to clipboard operation
QuickLib copied to clipboard

"Access violation" exception when deleting with Linq

Open estrify opened this issue 3 years ago • 7 comments

Hi,

To reproduce, please open "InterfacedLists" sample and add next line: ListObj.Where('Name = ?',['Lee']).Delete; before cout('Press ENTER to Exit',ccYellow);. Run the sample, and when ENTER is pressed, "Access violation" exception is thrown.

Best regards,

estrify avatar Nov 12 '21 07:11 estrify

Hi,

While the bug is resolved, I have been able to apply a workaround in the file Quick.Linq:

imagen ... ... ... imagen ... ... ... imagen

Best regards,

estrify avatar Nov 18 '21 09:11 estrify

Thanks for your report. I made some fixes and improvements to linq and generics to solve this. Please check now if all is correct.

exilon avatar Jan 27 '22 22:01 exilon

Hello,

Thank you for your support... I'm checking and now there is some kind of problem in the

Fields:=Table.Fields.Where('UI_Grid_Order > 0').OrderBy('UI_Grid_Order').Select()

Now, in some cases, with the same code as before, this select, that has to return 3 elements, seems to return first 3 elements correctly and nil for the rest, so Fields.Count returns 18 (incorrect) instead of 3. An access violation is raised when a loop tries to access the fourth element:

for Field in Table.Fields.Where('UI_Grid_Order > 0').OrderBy('UI_Grid_Order').Select() do

I don't know how to reproduce because I have two very very very similar situations, one works fine and the other has this problem...

Maybe this picture can help in some way: imagen

Regards,

estrify avatar Feb 03 '22 09:02 estrify

Hi,

I don't know if it's relevant: as I told you before, I have two very, very, very similar situations (same structure, different sets of data), one works fine and the other has this problem. I found that there is a difference between the code executed inside Quicklib (green is the correct case, red is the wrong one).

imagen

Both with exactly the same line of code: Fields:=Table.Fields.Where('UI_Grid_Order > 0').OrderBy('UI_Grid_Order').Select()

Regards,

estrify avatar Feb 03 '22 11:02 estrify

Hi, In the end I was able to reproduce this issue in a test case. I also attach as an image the output of this example. Regards,

imagen Test_Case.zip

estrify avatar Feb 03 '22 16:02 estrify

Solved! Thanks to your testcase was more easy to find it.

exilon avatar Mar 17 '22 22:03 exilon

Happy to contribute in some way to this fantastic library.

estrify avatar Mar 18 '22 22:03 estrify