Browse Source

Merge branch 'xnat-out-of-bound-fix'

* xnat-out-of-bound-fix:
  XnatTreeModel: Make sure last is at least first when inserting rows
Jean-Christophe Fillion-Robin 9 years ago
parent
commit
cdb75ce742
1 changed files with 2 additions and 1 deletions
  1. 2 1
      Libs/XNAT/Core/ctkXnatTreeModel.cpp

+ 2 - 1
Libs/XNAT/Core/ctkXnatTreeModel.cpp

@@ -291,7 +291,8 @@ void ctkXnatTreeModel::refresh(const QModelIndex& parent)
       // -> add it to the treeview
       if (addToTreeView)
       {
-        beginInsertRows(parent, 0, numChildren - 1);
+        int last = qMax(0, numChildren - 1);
+        beginInsertRows(parent, 0, last);
         item->appendChild(new ctkXnatTreeItem(child, item));
         endInsertRows();
         ++numChildren;