Fix possible crash when copying data into the internal copy-paste buffer

This fixes a crash which happens if you copy a range which contains at
least one cell of binary data and which has a hidden column in the
middle of it.
This commit is contained in:
Martin Kleusberg
2017-12-07 14:08:46 +01:00
parent 298d8c22c0
commit 968b8d55f0

View File

@@ -242,15 +242,18 @@ void ExtendedTableWidget::copy(const bool withHeaders)
qApp->clipboard()->clear();
// Copy selected data into internal copy-paste buffer
int columns = indices.last().column() - indices.first().column() + 1; // Make sure the layout of the internal buffer is rectangular
while (!indices.isEmpty()) {
QByteArrayList lst;
for (int i = 0; i < columns; ++i) {
lst << indices.first().data(Qt::EditRole).toByteArray();
indices.pop_front();
int last_row = indices.first().row();
QByteArrayList lst;
for(int i=0;i<indices.size();i++)
{
if(indices.at(i).row() != last_row)
{
m_buffer.push_back(lst);
lst.clear();
}
m_buffer.push_back(lst);
lst << indices.at(i).data(Qt::EditRole).toByteArray();
}
m_buffer.push_back(lst);
return;
}