diff mbox series

[5/8] kernel-shark-qt: Fix bug when loading plugins from session

Message ID 20181101214512.18684-6-ykaradzhov@vmware.com (mailing list archive)
State Accepted
Commit 6e2efe73cee3be047062f627e134a5d54f287b4a
Headers show
Series This series of patches contains various independent | expand

Commit Message

Yordan Karadzhov Nov. 1, 2018, 9:45 p.m. UTC
The session description file may contain plugins which are not available
at the moment when the session is loaded. These can be user-defined
plugins for example. The modification of the code introduced by this
patch deals with such a case.

Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark-qt/src/KsSession.cpp | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/kernel-shark-qt/src/KsSession.cpp b/kernel-shark-qt/src/KsSession.cpp
index 6cd1403..b7ef81c 100644
--- a/kernel-shark-qt/src/KsSession.cpp
+++ b/kernel-shark-qt/src/KsSession.cpp
@@ -545,7 +545,10 @@  void KsSession::loadPlugins(kshark_context *kshark_ctx, KsPluginManager *pm)
 {
 	kshark_config_doc *plugins = kshark_config_alloc(KS_CONFIG_JSON);
 	json_object *jplugins, *jlist, *jpl;
-	int length;
+	const char *pluginName;
+	QVector<int> pluginIds;
+	int length, index;
+	bool loaded;
 
 	if (!kshark_config_doc_get(_config, "Plugins", plugins) ||
 	    !kshark_type_check(plugins, "kshark.config.plugins"))
@@ -562,13 +565,13 @@  void KsSession::loadPlugins(kshark_context *kshark_ctx, KsPluginManager *pm)
 		length = json_object_array_length(jlist);
 		for (int i = 0; i < length; ++i) {
 			jpl = json_object_array_get_idx(jlist, i);
-			pm->_ksPluginList[i] =
-				json_object_get_string(json_object_array_get_idx(jpl, 0));
-
-			pm->_registeredKsPlugins[i] =
-				json_object_get_boolean(json_object_array_get_idx(jpl, 1));
+			pluginName = json_object_get_string(json_object_array_get_idx(jpl, 0));
+			index = pm->_ksPluginList.indexOf(pluginName);
+			loaded = json_object_get_boolean(json_object_array_get_idx(jpl, 1));
+			if (index >= 0 && loaded)
+				pluginIds.append(index);
 		}
 	}
 
-	pm->registerFromList(kshark_ctx);
+	pm->updatePlugins(pluginIds);
 }