aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYordan Karadzhov (VMware) <y.karadz@gmail.com>2019-07-23 15:52:02 +0300
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2019-07-23 16:30:35 -0400
commit41f08adfb323b0a8be52048933f753a929f5621e (patch)
tree8644121c252ad329cbb051d1fcaeedfb06b81b37
parent80940d027767d36db535943e35de4135443dd647 (diff)
downloadtrace-cmd-41f08adfb323b0a8be52048933f753a929f5621e.tar.gz
kernel-shark: Make KsEventsCheckBoxWidget::removeSystem more robust
The function has to be able to handle safely the case when the Checkbox tree widget is empty or it does not contain the item to be removed. Link: http://lore.kernel.org/linux-trace-devel/20190723125204.22799-2-y.karadz@gmail.com Reported-by: howaboutsynergy <howaboutsynergy@pm.me> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204277 Fixes: 4a02481fff (Remove all system=ftrace events from Record dialog) Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r--kernel-shark/src/KsWidgetsLib.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/kernel-shark/src/KsWidgetsLib.cpp b/kernel-shark/src/KsWidgetsLib.cpp
index 84afec9f..330230e6 100644
--- a/kernel-shark/src/KsWidgetsLib.cpp
+++ b/kernel-shark/src/KsWidgetsLib.cpp
@@ -749,10 +749,13 @@ QStringList KsEventsCheckBoxWidget::getCheckedEvents(bool option)
/** Remove a System from the Checkbox tree. */
void KsEventsCheckBoxWidget::removeSystem(QString name) {
- QTreeWidgetItem *item =
- _tree.findItems(name, Qt::MatchFixedString, 0)[0];
+ auto itemList = _tree.findItems(name, Qt::MatchFixedString, 0);
+ int index;
- int index = _tree.indexOfTopLevelItem(item);
+ if (itemList.isEmpty())
+ return;
+
+ index = _tree.indexOfTopLevelItem(itemList[0]);
if (index >= 0)
_tree.takeTopLevelItem(index);
}