diff mbox series

[3/3] kernel-shark: Set the location of .kshark directory via env. variable

Message ID 20190308171512.15372-4-ykaradzhov@vmware.com (mailing list archive)
State Superseded
Headers show
Series Tuning the KernelShark build system | expand

Commit Message

Yordan Karadzhov March 8, 2019, 5:15 p.m. UTC
The environment variable ${KS_CONF_DIR} can be used to specify the
directory where the "Last session" configuration file will be saved.

Suggested-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark/src/KsMainWindow.cpp | 19 ++++++++++++-------
 kernel-shark/src/KsMainWindow.hpp |  2 ++
 2 files changed, 14 insertions(+), 7 deletions(-)

Comments

Slavomir Kaslev March 11, 2019, 12:16 p.m. UTC | #1
On Fri, Mar 8, 2019 at 7:16 PM Yordan Karadzhov <ykaradzhov@vmware.com> wrote:
>
> The environment variable ${KS_CONF_DIR} can be used to specify the
> directory where the "Last session" configuration file will be saved.
>
> Suggested-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
> ---
>  kernel-shark/src/KsMainWindow.cpp | 19 ++++++++++++-------
>  kernel-shark/src/KsMainWindow.hpp |  2 ++
>  2 files changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/kernel-shark/src/KsMainWindow.cpp b/kernel-shark/src/KsMainWindow.cpp
> index 2d61c3f..7f39c14 100644
> --- a/kernel-shark/src/KsMainWindow.cpp
> +++ b/kernel-shark/src/KsMainWindow.cpp
> @@ -133,9 +133,7 @@ KsMainWindow::KsMainWindow(QWidget *parent)
>  KsMainWindow::~KsMainWindow()
>  {
>         kshark_context *kshark_ctx(nullptr);
> -       QString file = KS_CONF_DIR;
> -
> -       file += "/lastsession.json";
> +       QString file = _getLastSessionFile();
>
>         _updateSession();
>         kshark_save_config_file(file.toLocal8Bit().data(),
> @@ -368,12 +366,19 @@ void KsMainWindow::_open()
>                 loadDataFile(fileName);
>  }
>
> -void KsMainWindow::_restorSession()
> +QString KsMainWindow::_getLastSessionFile()
>  {
> -       QString file = KS_CONF_DIR;
> -       file += "/lastsession.json";
> +       const char *file = getenv("KS_CONF_DIR");
>
> -       loadSession(file);
> +       if (!file)
> +               file = KS_CONF_DIR;
> +
> +       return QString(file) +  "/lastsession.json";
> +}
> +
> +void KsMainWindow::_restorSession()

Nit: typo _restorSession()  -> _restoreSession()

> +{
> +       loadSession(_getLastSessionFile());
>         _graph.updateGeom();
>  }
>
> diff --git a/kernel-shark/src/KsMainWindow.hpp b/kernel-shark/src/KsMainWindow.hpp
> index 0727631..9b7ec6d 100644
> --- a/kernel-shark/src/KsMainWindow.hpp
> +++ b/kernel-shark/src/KsMainWindow.hpp
> @@ -153,6 +153,8 @@ private:
>
>         void _open();
>
> +       QString _getLastSessionFile();
> +
>         void _restorSession();
>
>         void _importSession();
> --
> 2.19.1
>
Yordan Karadzhov March 11, 2019, 5:44 p.m. UTC | #2
On 11.03.19 г. 14:16 ч., Slavomir Kaslev wrote:
>> +}
>> +
>> +void KsMainWindow::_restorSession()
> Nit: typo _restorSession()  -> _restoreSession()
> 
>> +{
>> +       loadSession(_getLastSessionFile());
>>          _graph.updateGeom();
>>   }

Very well spotted, thanks a lot!
I will fix this.
Y.
diff mbox series

Patch

diff --git a/kernel-shark/src/KsMainWindow.cpp b/kernel-shark/src/KsMainWindow.cpp
index 2d61c3f..7f39c14 100644
--- a/kernel-shark/src/KsMainWindow.cpp
+++ b/kernel-shark/src/KsMainWindow.cpp
@@ -133,9 +133,7 @@  KsMainWindow::KsMainWindow(QWidget *parent)
 KsMainWindow::~KsMainWindow()
 {
 	kshark_context *kshark_ctx(nullptr);
-	QString file = KS_CONF_DIR;
-
-	file += "/lastsession.json";
+	QString file = _getLastSessionFile();
 
 	_updateSession();
 	kshark_save_config_file(file.toLocal8Bit().data(),
@@ -368,12 +366,19 @@  void KsMainWindow::_open()
 		loadDataFile(fileName);
 }
 
-void KsMainWindow::_restorSession()
+QString KsMainWindow::_getLastSessionFile()
 {
-	QString file = KS_CONF_DIR;
-	file += "/lastsession.json";
+	const char *file = getenv("KS_CONF_DIR");
 
-	loadSession(file);
+	if (!file)
+		file = KS_CONF_DIR;
+
+	return QString(file) +  "/lastsession.json";
+}
+
+void KsMainWindow::_restorSession()
+{
+	loadSession(_getLastSessionFile());
 	_graph.updateGeom();
 }
 
diff --git a/kernel-shark/src/KsMainWindow.hpp b/kernel-shark/src/KsMainWindow.hpp
index 0727631..9b7ec6d 100644
--- a/kernel-shark/src/KsMainWindow.hpp
+++ b/kernel-shark/src/KsMainWindow.hpp
@@ -153,6 +153,8 @@  private:
 
 	void _open();
 
+	QString _getLastSessionFile();
+
 	void _restorSession();
 
 	void _importSession();