Fix crash and blocking condition while removing hidden columns at copy

It uses QMutableListIterator for removing while iterating and it can also
be made forwards, sot it is clearer.

This fixes #1256 in my environment.
This commit is contained in:
mgrojo
2017-12-07 18:31:54 +01:00
parent 409d02f9ea
commit 2e881659a5

View File

@@ -181,13 +181,11 @@ void ExtendedTableWidget::copy(const bool withHeaders)
// Remove all indices from hidden columns, because if we don't we might copy data from hidden columns as well which is very
// unintuitive; especially copying the rowid column when selecting all columns of a table is a problem because pasting the data
// won't work as expected.
for(int i=indices.size()-1;i>=0;)
{
if(isColumnHidden(indices.at(i).column()))
indices.removeAt(i);
else
i--;
}
QMutableListIterator<QModelIndex> i(indices);
while (i.hasNext()) {
if (isColumnHidden(i.next().column()))
i.remove();
}
// Abort if there's nothing to copy
if (indices.isEmpty())