vcl/jsdialog/jsdialogbuilder.cxx |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 21f64e9c7a275cd4ace83c90849ae8c6ccfed914
Author:     Andras Timar <[email protected]>
AuthorDate: Fri Mar 13 07:23:10 2026 +0100
Commit:     Miklos Vajna <[email protected]>
CommitDate: Mon Mar 16 10:46:37 2026 +0100

    jsdialog: fix JSTreeView::do_select sending wrong row to client
    
    The pos variable was modified by the iteration loop (pos--) before
    being sent in the action message, so the JS client always received
    -1 instead of the actual row position.
    
    Change-Id: I4ea2f0701692717d850080923c038acd50036509
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201706
    Tested-by: Andras Timar <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 638432a025b2..29d364914aa9 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -1768,6 +1768,7 @@ void JSTreeView::set_sensitive(const weld::TreeIter& 
rIter, bool bSensitive, int
 void JSTreeView::do_select(int pos)
 {
     assert(m_xTreeView->IsUpdateMode() && "don't select when frozen");
+    int nOrigPos = pos;
     if (pos == -1 || (pos == 0 && n_children() == 0))
         m_xTreeView->SelectAll(false);
     else
@@ -1786,7 +1787,7 @@ void JSTreeView::do_select(int pos)
 
     std::unique_ptr<jsdialog::ActionDataMap> pMap = 
std::make_unique<jsdialog::ActionDataMap>();
     (*pMap)[ACTION_TYPE ""_ostr] = "select";
-    (*pMap)["position"_ostr] = OUString::number(pos);
+    (*pMap)["position"_ostr] = OUString::number(nOrigPos);
     sendAction(std::move(pMap));
 }
 

Reply via email to