diff options
author | Yordan Karadzhov (VMware) <y.karadz@gmail.com> | 2019-07-24 18:40:39 +0300 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2019-07-24 14:40:04 -0400 |
commit | 2f641a1cfba76a291915d43ff9546de91b604ece (patch) | |
tree | 78c29ed46ecb06fac266640ee1dde31f1dfa7808 | |
parent | 7ca1204d28e97b9bcc5403e394cd77bc757038e7 (diff) | |
download | trace-cmd-2f641a1cfba76a291915d43ff9546de91b604ece.tar.gz |
kernel-shark: Handle corrupted configuration file for the Capture dialog
Error message will be printed to the console-like widget.
Link: http://lore.kernel.org/linux-trace-devel/20190724154039.23705-5-y.karadz@gmail.com
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/KsCaptureDialog.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/kernel-shark/src/KsCaptureDialog.cpp b/kernel-shark/src/KsCaptureDialog.cpp index e8efb381..dc1e9b27 100644 --- a/kernel-shark/src/KsCaptureDialog.cpp +++ b/kernel-shark/src/KsCaptureDialog.cpp @@ -209,6 +209,9 @@ void KsCaptureControl::_importSettings() tep_event **events; QString fileName; + auto lamImportError = [this] () { + emit print("ERROR: Unable to load the configuration file.\n"); + }; /** Get all available events. */ events = tep_list_events(_localTEP, TEP_EVENT_SORT_SYSTEM); @@ -218,21 +221,27 @@ void KsCaptureControl::_importSettings() "Kernel Shark Config files (*.json);;", _lastFilePath); - if (fileName.isEmpty()) + if (fileName.isEmpty()) { + lamImportError(); return; + } conf = kshark_open_config_file(fileName.toStdString().c_str(), "kshark.config.record"); - if (!conf) + if (!conf) { + lamImportError(); return; + } /* * Load the hash table of selected events from the configuration * document. */ jevents = kshark_config_alloc(KS_CONFIG_JSON); - if (!kshark_config_doc_get(conf, "Events", jevents)) + if (!kshark_config_doc_get(conf, "Events", jevents)) { + lamImportError(); return; + } eventHash = tracecmd_filter_id_hash_alloc(); nIds = kshark_import_event_filter(_localTEP, eventHash, "Events", jevents); |