From 91dc7ddb283771d1d2a29fe327770d9f0080304c Mon Sep 17 00:00:00 2001
From: Yuchen Deng <loaden@gmail.com>
Date: Sun, 28 Oct 2012 12:12:04 +0800
Subject: [PATCH] HistoryCompleter: Fix removeRows scope

Change-Id: Ia951c1e816a4c333ebf099d774405c41003c4966
Reviewed-by: hjk <hjk121@nokiamail.com>
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
---
 src/libs/utils/historycompleter.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/libs/utils/historycompleter.cpp b/src/libs/utils/historycompleter.cpp
index 8ae061ca1bd..219c6153951 100644
--- a/src/libs/utils/historycompleter.cpp
+++ b/src/libs/utils/historycompleter.cpp
@@ -129,8 +129,12 @@ QVariant HistoryCompleterPrivate::data(const QModelIndex &index, int role) const
 
 bool HistoryCompleterPrivate::removeRows(int row, int count, const QModelIndex &parent)
 {
-    beginRemoveRows (parent, row, row + count);
-    list.removeAt(row);
+    QTC_ASSERT(theSettings, return false);
+    if (row + count > list.count())
+        return false;
+    beginRemoveRows(parent, row, row + count -1);
+    for (int i = 0; i < count; ++i)
+        list.removeAt(row);
     theSettings->setValue(historyKey, list);
     endRemoveRows();
     return true;
-- 
GitLab