diff mbox series

[4/4] kernel-shark: Handle corrupted configuration file for the Capture dialog

Message ID 20190724154039.23705-5-y.karadz@gmail.com (mailing list archive)
State Accepted
Commit 2f641a1cfba76a291915d43ff9546de91b604ece
Headers show
Series Fixes for Capture needed befor KS 1.0 | expand

Commit Message

Yordan Karadzhov July 24, 2019, 3:40 p.m. UTC
Error message will be printed to the console-like widget.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 kernel-shark/src/KsCaptureDialog.cpp | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/kernel-shark/src/KsCaptureDialog.cpp b/kernel-shark/src/KsCaptureDialog.cpp
index 02bbbbc..addd41d 100644
--- a/kernel-shark/src/KsCaptureDialog.cpp
+++ b/kernel-shark/src/KsCaptureDialog.cpp
@@ -201,6 +201,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);
@@ -210,21 +213,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);