summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-08-06 11:54:58 (GMT)
committerGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-08-06 12:00:28 (GMT)
commite1fe84cb8a16e4ea9425f1f6533dc75afe2fd4c4 (patch)
treebac7835d3c6d763e7c753c3a2cc5be1cfd53d1d8 /src/gui
parent576af5e57831c7065d621f468c067fca8ebc2fe5 (diff)
downloadQt-e1fe84cb8a16e4ea9425f1f6533dc75afe2fd4c4.zip
Qt-e1fe84cb8a16e4ea9425f1f6533dc75afe2fd4c4.tar.gz
Qt-e1fe84cb8a16e4ea9425f1f6533dc75afe2fd4c4.tar.bz2
QStandardItem::takeRow() would crash when it had no columns.
Reviewed-by: olivier
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/itemviews/qstandarditemmodel.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/gui/itemviews/qstandarditemmodel.cpp b/src/gui/itemviews/qstandarditemmodel.cpp
index e71d8f9..6f99fb5 100644
--- a/src/gui/itemviews/qstandarditemmodel.cpp
+++ b/src/gui/itemviews/qstandarditemmodel.cpp
@@ -1745,15 +1745,17 @@ QList<QStandardItem*> QStandardItem::takeRow(int row)
if (d->model)
d->model->d_func()->rowsAboutToBeRemoved(this, row, row);
QList<QStandardItem*> items;
- int index = d->childIndex(row, 0);
- int col_count = d->columnCount();
- for (int column = 0; column < col_count; ++column) {
- QStandardItem *ch = d->children.at(index + column);
- if (ch)
- ch->d_func()->setParentAndModel(0, 0);
- items.append(ch);
+ int index = d->childIndex(row, 0); // Will return -1 if there are no columns
+ if (index != -1) {
+ int col_count = d->columnCount();
+ for (int column = 0; column < col_count; ++column) {
+ QStandardItem *ch = d->children.at(index + column);
+ if (ch)
+ ch->d_func()->setParentAndModel(0, 0);
+ items.append(ch);
+ }
+ d->children.remove(index, col_count);
}
- d->children.remove(index, col_count);
d->rows--;
if (d->model)
d->model->d_func()->rowsRemoved(this, row, 1);