From 9c334767305ec0b24bdf05f3eb3df1fa41aa330c Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Sat, 7 Dec 2024 23:02:08 +0100 Subject: [PATCH] tdf#130857 qt weld: Fix incorrect param order for row/col In QtInstanceTreeView::get_id, the nPos param is the row number, but was incorrectly passed as the second parameter to QStandardItemModel::index [1] which is for the column. Swap the params to fix that. Passing incorrectly would trigger a crash in a WIP branch for Writer's "Tools" -> "XML Filter Settings" dialog when clicking on the second row, as the ID data is only set for the item in the first, not the second column, so `pInfo` in XMLFilterSettingsDialog::updateStates would be null. Backtrace: 1 XMLFilterSettingsDialog::updateStates xmlfiltersettingsdialog.cxx 183 0x7f3eb862194e 2 XMLFilterSettingsDialog::SelectionChangedHdl_Impl xmlfiltersettingsdialog.cxx 153 0x7f3eb8621859 3 XMLFilterSettingsDialog::LinkStubSelectionChangedHdl_Impl xmlfiltersettingsdialog.cxx 151 0x7f3eb861e8cd 4 Link::Call link.hxx 111 0x7f3eeb997aa1 5 weld::TreeView::signal_selection_changed weld.hxx 989 0x7f3eeb99733c 6 QtInstanceTreeView::handleSelectionChanged QtInstanceTreeView.cxx 781 0x7f3eeb98cb2d 7 QtPrivate::FunctorCall, QtPrivate::List<>, void, void (QtInstanceTreeView:: *)()>::call(void (QtInstanceTreeView:: *)(), QtInstanceTreeView *, void * *)::{lambda()#1}::operator()() const qobjectdefs_impl.h 127 0x7f3eeb998141 8 QtPrivate::FunctorCallBase::call_internal, QtPrivate::List<>, void, void (QtInstanceTreeView:: *)()>::call(void (QtInstanceTreeView:: *)(), QtInstanceTreeView *, void * *)::{lambda()#1}>(void * *, QtPrivate::FunctorCall, QtPrivate::List<>, void, void (QtInstanceTreeView:: *)()>::call(void (QtInstanceTreeView:: *)(), QtInstanceTreeView *, void * *)::{lambda()#1}&&) qobjectdefs_impl.h 65 0x7f3eeb998079 9 QtPrivate::FunctorCall, QtPrivate::List<>, void, void (QtInstanceTreeView:: *)()>::call(void (QtInstanceTreeView:: *)(), QtInstanceTreeView *, void * *) qobjectdefs_impl.h 126 0x7f3eeb997fab 10 QtPrivate::FunctionPointer::call, void>(void (QtInstanceTreeView:: *)(), QtInstanceTreeView *, void * *) qobjectdefs_impl.h 174 0x7f3eeb997f2d 11 QtPrivate::QCallableObject, void>::impl(int, QtPrivate::QSlotObjectBase *, QObject *, void * *, bool *) qobjectdefs_impl.h 545 0x7f3eeb997e56 12 QtPrivate::QSlotObjectBase::call qobjectdefs_impl.h 461 0x7f3eeaa5ce22 13 doActivate qobject.cpp 4139 0x7f3eeab1c644 14 QMetaObject::activate qobject.cpp 4199 0x7f3eeab121b3 15 QMetaObject::activate qobjectdefs.h 306 0x7f3eeaf93da5 16 QItemSelectionModel::selectionChanged moc_qitemselectionmodel.cpp 390 0x7f3eeaf85b76 17 QItemSelectionModel::emitSelectionChanged qitemselectionmodel.cpp 2029 0x7f3eeaf87a2f 18 QItemSelectionModel::select qitemselectionmodel.cpp 1372 0x7f3eeaf872f9 19 QTreeViewPrivate::select qtreeview.cpp 4016 0x7f3ee906f2ec 20 QTreeView::setSelection qtreeview.cpp 2393 0x7f3ee906eaae ... Change-Id: Icf6b3004ab95991da69c0ff86201421d620aaa43 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178066 Reviewed-by: Michael Weghorn Tested-by: Jenkins --- vcl/qt5/QtInstanceTreeView.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcl/qt5/QtInstanceTreeView.cxx b/vcl/qt5/QtInstanceTreeView.cxx index 10fb36413f6f..8e26055cf1f9 100644 --- a/vcl/qt5/QtInstanceTreeView.cxx +++ b/vcl/qt5/QtInstanceTreeView.cxx @@ -301,7 +301,7 @@ OUString QtInstanceTreeView::get_id(int nPos) const OUString sId; GetQtInstance().RunInMainThread([&] { - QVariant aRoleData = m_pModel->data(m_pModel->index(0, nPos), ROLE_ID); + QVariant aRoleData = m_pModel->data(m_pModel->index(nPos, 0), ROLE_ID); if (aRoleData.canConvert()) sId = toOUString(aRoleData.toString()); });