Created attachment 156124 [details] A sample library for listbox item selection testing, packed as extension Having a list box with many elements, and running code like Dim selItems(1000) For i = lBound(selItems) To uBound(selItems) selItems(i) = i Next i oListBox.selectItemsPos(selItems, true) is very slow, especially compared to doing the same with the list box hidden (i.e., the call to selectItemsPos wrapped into calls to setVisible(false)...setVisible(true)). In debug build, the process of the selection is actually visible, i.e. not an atomic operation, despite not multiple selectItemPos called, but a single selectItemsPos. The attachment contains a basic module and a dialog in a library, exported as an extension for convenience; to test, install the OXT, and run Main in ListBoxTest/Module1. All three buttons below the list box in the dialog allow to deselect then re-select everything; they show elapsed time in seconds after the run.
Caolán, do you know if it's expected that XListBox::selectItemsPos behaves as multiple separate refreshing select operations?
selectItemsPos is implemented by VCLXListBox::selectItemsPos in toolkit/source/awt/vclxwindows.cxx and that loops over each index and calls ListBox::SelectEntryPos in a loop where SelectEntryPos is in vcl/source/control/listbox.cxx where the slow bits seems to be the very expensive CallEventListeners calls checking VclEventId::ListboxSelect uses I don't think there is any use of the position argument passed in so I don't think that matters too much, consumers seem to just look up what is selected themselves, so its plausible that we could get away with a single CallEventListener in this scenario https://gerrit.libreoffice.org/#/c/83771/
that would bring it down to 2 seconds for me and with https://gerrit.libreoffice.org/#/c/83774/ added on I get 0 seconds
Caolán McNamara committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/c8afb4000f178badaf63c2f38fd3fbc12ec832f3 tdf#129037 add a way to select multiple entries of a ListBox together It will be available in 6.5.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Caolán McNamara committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/85578a6f9ca9dfb1e384d8d1f6edd8219a2ac493 tdf#129037 disable updates during multiselection It will be available in 6.5.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Thank you very much Caolán!