https://bugs.kde.org/show_bug.cgi?id=452316

            Bug ID: 452316
           Summary: KExtraColumnsProxyModel adressing wrong index
           Product: frameworks-kitemmodels
           Version: unspecified
          Platform: unspecified
                OS: Unspecified
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: kdelibs-b...@kde.org
          Reporter: kaloskaga...@gmail.com
  Target Milestone: ---

`KExtraColumnsProxyModel::extraColumnData()` and
`KExtraColumnsProxyModel::setExtraColumnData()` are receiving a
`index.parent()` but they might be receiving the same `index` passed to
`KExtraColumnsProxyModel::data()` and `KExtraColumnsProxyModel::setData()`.

I see no reason why the interface would be called with an invalid parent index
for example. Here is my suggestion for the fix :

```cpp
QVariant KExtraColumnsProxyModel::data(const QModelIndex &index, int role)
const
{
    Q_D(const KExtraColumnsProxyModel);
    const int extraCol = extraColumnForProxyColumn(index.column());
    if (extraCol >= 0 && !d->m_extraHeaders.isEmpty()) {
        return extraColumnData(/*index.parent()*/ index, index.row(), extraCol,
role);
    }
    return sourceModel()->data(mapToSource(index), role);
}
```

```cpp
bool KExtraColumnsProxyModel::setData(const QModelIndex &index, const QVariant
&value, int role)
{
    Q_D(const KExtraColumnsProxyModel);
    const int extraCol = extraColumnForProxyColumn(index.column());
    if (extraCol >= 0 && !d->m_extraHeaders.isEmpty()) {
        return setExtraColumnData(/*index.parent()*/index, index.row(),
extraCol, value, role);
    }
    return sourceModel()->setData(mapToSource(index), value, role);
}
```

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to