linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: linux-trace-devel@vger.kernel.org
Cc: hongzhan.chen@intel.com, jan.kiszka@siemens.com,
	"Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Subject: [PATCH 2/2] kernel-shark: Load 'ctrl' interface for user plugins
Date: Wed, 16 Feb 2022 10:29:09 +0200	[thread overview]
Message-ID: <20220216082909.614231-3-y.karadz@gmail.com> (raw)
In-Reply-To: <20220216082909.614231-1-y.karadz@gmail.com>

Currently, the 'ctrl' interface of all plugins gets called in the
constructor of the MainWindow widget. This works well for the built-in
plugins because the list of those plugins is known in advance. However,
the list of user plugins is populated dynamically, hence it is not known
by the time the constructor of the widget is called. The problem is
solved by making sure we call the 'ctrl' interface every time we load
a user plugin from the menus of the GUI or at start as a command line
option.

Reported-by: Hongzhan Chen <hongzhan.chen@intel.com>
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 src/KsUtils.cpp | 35 +++++++++++++++++++++++++----------
 src/KsUtils.hpp |  2 ++
 2 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/src/KsUtils.cpp b/src/KsUtils.cpp
index a22c445..e3e16ae 100644
--- a/src/KsUtils.cpp
+++ b/src/KsUtils.cpp
@@ -1190,6 +1190,20 @@ QVector<int> KsPluginManager::getPluginsByStatus(int sd, int status) const
 	return vec;
 }
 
+void KsPluginManager::_registerCtrlInterface(kshark_plugin_list *plugin)
+{
+	if (!plugin->handle || !plugin->ctrl_interface)
+		return;
+
+	void *dialogPtr = plugin->ctrl_interface(parent());
+	if (dialogPtr) {
+		QWidget *dialog = static_cast<QWidget *>(dialogPtr);
+
+		if (dialog && _pluginDialogs.indexOf(dialog) < 0)
+			_pluginDialogs.append(dialog);
+	}
+}
+
 /**
  * @brief Loop over the registered plugins and register all plugin-defined
  *	  menus (if any).
@@ -1203,14 +1217,7 @@ void KsPluginManager::registerPluginMenues()
 		return;
 
 	for (plugin = kshark_ctx->plugins; plugin; plugin = plugin->next)
-		if (plugin->handle && plugin->ctrl_interface) {
-			void *dialogPtr = plugin->ctrl_interface(parent());
-			if (dialogPtr) {
-				QWidget *dialog =
-					static_cast<QWidget *>(dialogPtr);
-				_pluginDialogs.append(dialog);
-			}
-		}
+		_registerCtrlInterface(plugin);
 }
 
 std::string KsPluginManager::_pluginLibFromName(const QString &plugin)
@@ -1247,11 +1254,17 @@ std::string KsPluginManager::_pluginNameFromLib(const QString &plugin)
  * @param pluginNames: Provide here the names of the plugin (as in the
  *		       CMake-generated header file) or the names of the
  *		       plugin's library files (.so including path).
- * 		       The names must be comma separated.
+ *		       The names must be comma separated.
  */
 void KsPluginManager::registerPlugins(const QString &pluginNames)
 {
-	_userPlugins.append(_loadPluginList(pluginNames.split(',')));
+	QVector<kshark_plugin_list *> plugins;
+
+	plugins = _loadPluginList(pluginNames.split(','));
+	for (auto const &p: plugins)
+		_registerCtrlInterface(p);
+
+	_userPlugins.append(plugins);
 }
 
 /**
@@ -1369,6 +1382,8 @@ void KsPluginManager::addPlugins(const QStringList &fileNames,
 		return;
 
 	plugins = _loadPluginList(fileNames);
+	for (auto const &p: plugins)
+		_registerCtrlInterface(p);
 	_userPlugins.append(plugins);
 
 	if (streamIds.isEmpty())
diff --git a/src/KsUtils.hpp b/src/KsUtils.hpp
index 1a97d9e..e42b6da 100644
--- a/src/KsUtils.hpp
+++ b/src/KsUtils.hpp
@@ -330,6 +330,8 @@ private:
 	QVector<kshark_plugin_list *>
 	_loadPluginList(const QStringList &plugins);
 
+	void _registerCtrlInterface(kshark_plugin_list *plugin);
+
 	std::string _pluginLibFromName(const QString &plugin);
 
 	std::string _pluginNameFromLib(const QString &plugin);
-- 
2.32.0


  parent reply	other threads:[~2022-02-16  8:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-16  8:29 [PATCH 0/2] kernel-shark: Fixes needed by the Xenomai plugin Yordan Karadzhov (VMware)
2022-02-16  8:29 ` [PATCH 1/2] kernel-shark: Add KsPluginsGUI.hpp/.cpp Yordan Karadzhov (VMware)
2022-02-16  8:29 ` Yordan Karadzhov (VMware) [this message]
2022-02-21 12:31 ` [PATCH 0/2] kernel-shark: Fixes needed by the Xenomai plugin Yordan Karadzhov

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=20220216082909.614231-3-y.karadz@gmail.com \
    --to=y.karadz@gmail.com \
    --cc=hongzhan.chen@intel.com \
    --cc=jan.kiszka@siemens.com \
    --cc=linux-trace-devel@vger.kernel.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).