SortFilterProxyModel icon indicating copy to clipboard operation
SortFilterProxyModel copied to clipboard

Crashes when QML debugging is enabled

Open timangus opened this issue 7 years ago • 2 comments

One thing I've noticed recently is that (presumably) changes in the QML debugger have started to cause crashes in qqsfpm. It seems that the debugger sometimes ends up (for whatever reason) in calling qqsfpm::data with an invalid index, which ultimately results in sourceModel() returning nullptr, and thus a nullptr de-reference. My fix is as follows, which is probably no bad thing anyway.

QVariant QQmlSortFilterProxyModel::data(const QModelIndex &index, int role) const
{
    if(!index.isValid())
        return {};

    return sourceData(mapToSource(index), role);
}

timangus avatar May 11 '18 14:05 timangus

Thanks, I'll look into that

oKcerG avatar May 11 '18 22:05 oKcerG

Or perhaps I should be using QAbstractItemModel::checkIndex()!

https://www.kdab.com/new-in-qt-5-11-improvements-to-the-model-view-apis-part-1/

timangus avatar May 15 '18 15:05 timangus