Skip to content

FolderView Positioner: fix rows insert and remove

Marco Martin requested to merge work/mart/positioner into master

The positioner "proxy" model had problems both in rows insertion and removal.

when an icon is dropped in an empty desktop area as the new "last" position, the positioner model creates new empty items for the GridView until it reaches the cell of the drop position.

This broke because of connection slot invocation order: the connection to QAbstractItemModel::rowsInserted in FolderModel constructor was executed before the connection in positioner. In turn that connection emitted move, which invoked move on Positioner, which at this point thinks its still in the first rows insertion transaction, because its slot has not been executed yet, and m_beginInsertRowsCalled is still true, so there won't be a "correct" new beginInsertRows called. Make it a Queued connection to push it back.

In the same way, when dragging from a "last" position, the Positioner model will remove all the trailing empty items. But it modified m_proxyToSource (from which rowCount() depends) before calling beginRemoveRows, sending the model into an inconsitent state and causing an assert. Make sure that m_proxyToSource is touched only after beginRemoveRows.

BUG:481254 BUG:466337

Merge request reports