@@ -28,13 +28,19 @@ KsSession::~KsSession()
}
/** Import a user session from a Json file. */
-void KsSession::importFromFile(QString jfileName)
+bool KsSession::importFromFile(QString jfileName)
{
- if (_config)
+ kshark_config_doc *configTmp =
+ kshark_open_config_file(jfileName.toStdString().c_str(),
+ "kshark.config.session");
+
+ if (configTmp) {
kshark_free_config_doc(_config);
+ _config = configTmp;
+ return true;
+ }
- _config = kshark_open_config_file(jfileName.toStdString().c_str(),
- "kshark.config.session");
+ return false;
}
/** Export the current user session from a Json file. */
@@ -37,7 +37,7 @@ public:
/** Get the configuration document object. */
kshark_config_doc *getConfDocPtr() const {return _config;}
- void importFromFile(QString jfileName);
+ bool importFromFile(QString jfileName);
void exportToFile(QString jfileName);
The function has a better handling of the case when the session description file cannot be loaded. It returns true on success, otherwise false. We need this return flag in order to provide adequate error message in the case when this operation fails. Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com> --- kernel-shark/src/KsSession.cpp | 14 ++++++++++---- kernel-shark/src/KsSession.hpp | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-)