linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org,
	"Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Subject: [PATCH 4/4] kernel-shark: Handle corrupted configuration file for the Capture dialog
Date: Wed, 24 Jul 2019 18:40:39 +0300	[thread overview]
Message-ID: <20190724154039.23705-5-y.karadz@gmail.com> (raw)
In-Reply-To: <20190724154039.23705-1-y.karadz@gmail.com>

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 --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);
-- 
2.20.1


      parent reply	other threads:[~2019-07-24 15:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-24 15:40 [PATCH 0/3] Fixes for Capture needed befor KS 1.0 Yordan Karadzhov (VMware)
2019-07-24 15:40 ` [PATCH 1/4] kernel-shark: kshark_import_event_filter() tolerates non-existing events Yordan Karadzhov (VMware)
2019-07-24 15:40 ` [PATCH 2/4] kernel-shark: Allow KsCaptureControl widget to print text to the console Yordan Karadzhov (VMware)
2019-07-24 15:40 ` [PATCH 3/4] kernel-shark: Handle errors when loading Capture configurations Yordan Karadzhov (VMware)
2019-07-24 15:40 ` Yordan Karadzhov (VMware) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190724154039.23705-5-y.karadz@gmail.com \
    --to=y.karadz@gmail.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).