Windows 7 x64, Lazarus 2.2.0
ListView1.Items.Count := 20000; // Probably somewhere later, but for demo in its elementary form here: if ListView1.Selected = nil then -> boom! 20000 items will be instantiated at once, destroying virtualism // Just saw that it is the same with "SelCount": if ListView1.SelCount > 0 then -> boom! all 20000 items will be instantiated at once
Could youYou're right. After that, when press Button 2, all the elements are requested.
- set the ListView to "MultiSelect" (problem only here)
You are right about the SelCount (but that was only an observation besides).Since the ListView1.Handle has not been created, Lazarus does not call the OS function.
But if you move the assignment to Items.Count and the "if ListView1.SelCount" etc both from within Button1Click into FormCreate, it will happen too (strange).
Could apply it directy to my 2.2.- If i understand the patch file format right,You're welcome! In my opinion the chance of regression for this patch is minimal.
it's simply about to apply this additional if-condition before the for loop.
Works very fine!
Btw it's essentially the same (but shorter coded) than my workaround proposedWhere do you proposed a workaround? In the bug tracker?
It killed my app in at least 3 different respects. Whereas i could use the workaround without any problems.
It's based (and slightly modified) on a proposal from yourself around July 28, 2021Apparently the first bad sectors already appeared in my head. :D
if OwnerData And (FSelectedIdx=-1) then begin ... Exit; end; ... for i := 0 to Items.Count - 1 do
GetMem, is there even an interest to have such kind of workaround? No substantially feedback Yes/No in this respect so far.I don't know. Personally I would revert d6c215a4, this would solve the speed issue, then I would try to address the "last instead of first selected element on multiselect" separately. In my opinion the later issue is not critical, it's just a mild inconvenience at best. However fixing it is no walk in the park and most likely will introduce new issues.
Everybody would like to have a proper solution, where the problem does not arise in the first place. Me too.
The more because on application level there will be still consecutive struggles with Item loops.
Is such a workaround (which is not a comprehensive solution, as Martin pointed out) in the path of decision?
I don't know. Meanwhile i'm loosing energy to trigger this topic again and again and close to give up.
One very little thing needs to be mentioned though (not occuring with a pure 2.2 customlistview.inc). Ownerdata + Multiselect + patch: "Shift" and VK_UP will return nil as result value for "Selected". Test project and workaround proposal (a simple 2-liner) do exist. I hadn't that mentioned here yet for not to flood even more stuff or confusion.Is the attached patch OK? I could not reproduce the problem on Linux.
Yes! (if i interprete the patch file right): that matches exactly the workaround i would have proposed:A patch does not need interpreting. It represents the change exactly. The tool chain supports that exact information, meaning patches can be generated and applied easily.