From 16584dc70ef9121876ded1604daf32774d1862e2 Mon Sep 17 00:00:00 2001 From: Weng Xuetian Date: Tue, 1 Mar 2016 08:05:23 -0800 Subject: [PATCH] Workaround by always reset model when insert and remove from model. CCBUG: 352055 --- applets/systemtray/plugin/tasklistmodel.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/applets/systemtray/plugin/tasklistmodel.cpp b/applets/systemtray/plugin/tasklistmodel.cpp index 1fa306c82..473d61cdc 100644 --- a/applets/systemtray/plugin/tasklistmodel.cpp +++ b/applets/systemtray/plugin/tasklistmodel.cpp @@ -102,10 +102,10 @@ void SystemTray::TaskListModel::addTask(Task *task) { if (!m_tasks.contains(task)) { auto it = qLowerBound(m_tasks.begin(), m_tasks.end(), task, taskLessThan); - int index = it - m_tasks.begin(); - beginInsertRows(QModelIndex(), index, index); + // use ResetModel as a workaround for bug 352055 + beginResetModel(); m_tasks.insert(it, task); - endInsertRows(); + endResetModel(); } } @@ -113,9 +113,10 @@ void SystemTray::TaskListModel::removeTask(Task *task) { int index = m_tasks.indexOf(task); if (index >= 0 ) { - beginRemoveRows(QModelIndex(), index, index); + // use ResetModel as a workaround for bug 352055 + beginResetModel(); m_tasks.removeAt(index); - endRemoveRows(); + endResetModel(); } }