Skip to content

SortProxyModel: endMoveRows() will be called even if beginMoveRows() return false #50

@BLumia

Description

@BLumia

Related code:

bool ok = beginMoveRows(QModelIndex(), movedRow, movedRow + moveCount - 1, QModelIndex(), destinationRow);
if (!ok)
{
qWarning() << "moveRows from" << movedRow << "up to" << movedRow + moveCount - 1 << "to"
<< destinationRow;
QStringList contents;
contents.reserve(rowCount());
for (int row = 0; row < rowCount(); ++row)
{
contents << index(row).data(m_sortRole).toString();
}
qWarning() << "moving failed. Current contents:" << contents.join(QLatin1String(", "));
}
auto rotateEnd = successor(unorderedIt);
std::rotate(it, it + moveCount, rotateEnd);
endMoveRows();

The issue may occur when we attempt to call reorder() when reorder() is already running, which might lead to a crash.

Note: I'm using a modified version of the SortProxyModel which also handle modelReset() in order to support QML. I originally converted it to resetInternalData() + handleDataChanged() which caused the issue I got. I'm not exactly sure (haven't verified) if this issue can be triggered in unmodified version of SortProxyModel, so I'm just opening an issue here just in case.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions