From 0d6f5b470b1b1dfc766ad1580f5d3634c99412ef Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Thu, 19 Jan 2017 19:14:55 +0100 Subject: [PATCH] [Companion] Crash fixed --- companion/src/modelslist.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/companion/src/modelslist.cpp b/companion/src/modelslist.cpp index 38f6e847e..95ecea118 100644 --- a/companion/src/modelslist.cpp +++ b/companion/src/modelslist.cpp @@ -207,11 +207,13 @@ QModelIndex TreeModel::parent(const QModelIndex & index) const bool TreeModel::removeRows(int position, int rows, const QModelIndex & parent) { TreeItem * parentItem = getItem(parent); - bool success; + bool success = true; - beginRemoveRows(parent, position, position + rows - 1); - success = parentItem->removeChildren(position, rows); - endRemoveRows(); + if (position >= 0 && rows > 0) { + beginRemoveRows(parent, position, position + rows - 1); + success = parentItem->removeChildren(position, rows); + endRemoveRows(); + } return success; }