瀏覽代碼

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 年之前
父節點
當前提交
cdb75ce742
共有 1 個文件被更改,包括 2 次插入1 次删除
  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;