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<weld::TreeView&, void>::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<std::integer_sequence<unsigned long>, QtPrivate::List<>, void, void (QtInstanceTreeView:: *)()>::call(void (QtInstanceTreeView:: *)(), QtInstanceTreeView *, void * *)::{lambda()#1}::operator()() const qobjectdefs_impl.h 127 0x7f3eeb998141
    8 QtPrivate::FunctorCallBase::call_internal<void, QtPrivate::FunctorCall<std::integer_sequence<unsigned long>, QtPrivate::List<>, void, void (QtInstanceTreeView:: *)()>::call(void (QtInstanceTreeView:: *)(), QtInstanceTreeView *, void * *)::{lambda()#1}>(void * *, QtPrivate::FunctorCall<std::integer_sequence<unsigned long>, QtPrivate::List<>, void, void (QtInstanceTreeView:: *)()>::call(void (QtInstanceTreeView:: *)(), QtInstanceTreeView *, void * *)::{lambda()#1}&&) qobjectdefs_impl.h 65 0x7f3eeb998079
    9 QtPrivate::FunctorCall<std::integer_sequence<unsigned long>, QtPrivate::List<>, void, void (QtInstanceTreeView:: *)()>::call(void (QtInstanceTreeView:: *)(), QtInstanceTreeView *, void * *) qobjectdefs_impl.h 126 0x7f3eeb997fab
    10 QtPrivate::FunctionPointer<void (QtInstanceTreeView:: *)()>::call<QtPrivate::List<>, void>(void (QtInstanceTreeView:: *)(), QtInstanceTreeView *, void * *) qobjectdefs_impl.h 174 0x7f3eeb997f2d
    11 QtPrivate::QCallableObject<void (QtInstanceTreeView:: *)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase *, QObject *, void * *, bool *) qobjectdefs_impl.h 545 0x7f3eeb997e56
    12 QtPrivate::QSlotObjectBase::call qobjectdefs_impl.h 461 0x7f3eeaa5ce22
    13 doActivate<false> qobject.cpp 4139 0x7f3eeab1c644
    14 QMetaObject::activate qobject.cpp 4199 0x7f3eeab121b3
    15 QMetaObject::activate<void, QItemSelection, QItemSelection> 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
    ... <More>

Change-Id: Icf6b3004ab95991da69c0ff86201421d620aaa43
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178066
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
This commit is contained in:
Michael Weghorn 2024-12-07 23:02:08 +01:00
parent c91edf5e57
commit 9c33476730

View file

@ -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<QString>())
sId = toOUString(aRoleData.toString());
});