diff mbox series

[04/12] kernel-shark: Error message if the opening of the session file fails

Message ID 20190314151012.905-5-ykaradzhov@vmware.com (mailing list archive)
State Accepted
Headers show
Series Various modifications and fixes toward KS 1.0 | expand

Commit Message

Yordan Karadzhov March 14, 2019, 3:10 p.m. UTC
Here we add proper handling of the case when the loading of the
session description file fails.

Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark/src/KsMainWindow.cpp | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Slavomir Kaslev March 15, 2019, 10:23 a.m. UTC | #1
On Thu, Mar 14, 2019 at 5:11 PM Yordan Karadzhov <ykaradzhov@vmware.com> wrote:
>
> Here we add proper handling of the case when the loading of the
> session description file fails.
>
> Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
> ---
>  kernel-shark/src/KsMainWindow.cpp | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/kernel-shark/src/KsMainWindow.cpp b/kernel-shark/src/KsMainWindow.cpp
> index 91e0c9f..44221f6 100644
> --- a/kernel-shark/src/KsMainWindow.cpp
> +++ b/kernel-shark/src/KsMainWindow.cpp
> @@ -1010,7 +1010,16 @@ void KsMainWindow::loadSession(const QString &fileName)
>                 return;
>         }
>
> -       _session.importFromFile(fileName);
> +       if (!_session.importFromFile(fileName)) {
> +               QString text("Unable to open session description file ");
> +
> +               text.append(fileName);
> +               text.append(".\n");

Imo this is cleaner with string interpolation, e.g.

        QString text = QString("Unable to open session description
file %1.\n").arg(fileName);

-- Slavi

> +               _error(text, "loadSessErr1", true, true);
> +
> +               return;
> +       }
> +
>         _session.loadPlugins(kshark_ctx, &_plugins);
>
>         QString dataFile(_session.getDataFile(kshark_ctx));
> --
> 2.19.1
>
diff mbox series

Patch

diff --git a/kernel-shark/src/KsMainWindow.cpp b/kernel-shark/src/KsMainWindow.cpp
index 91e0c9f..44221f6 100644
--- a/kernel-shark/src/KsMainWindow.cpp
+++ b/kernel-shark/src/KsMainWindow.cpp
@@ -1010,7 +1010,16 @@  void KsMainWindow::loadSession(const QString &fileName)
 		return;
 	}
 
-	_session.importFromFile(fileName);
+	if (!_session.importFromFile(fileName)) {
+		QString text("Unable to open session description file ");
+
+		text.append(fileName);
+		text.append(".\n");
+		_error(text, "loadSessErr1", true, true);
+
+		return;
+	}
+
 	_session.loadPlugins(kshark_ctx, &_plugins);
 
 	QString dataFile(_session.getDataFile(kshark_ctx));