Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to appropriately use ctkPluginFrameworkLauncher::stop() #1161

Open
haomehaode opened this issue Jan 2, 2024 · 0 comments
Open

How to appropriately use ctkPluginFrameworkLauncher::stop() #1161

haomehaode opened this issue Jan 2, 2024 · 0 comments

Comments

@haomehaode
Copy link

haomehaode commented Jan 2, 2024

Dear CTK Developer,
I am facing a strange problem as I quit a GUI app. I believe it is related to multiple threads. Here is a snapshot of the main function where the ctkPluginFramework is initialized. To test if all plugin could be removed once the stop function is called, a line is added as follows,

QApplication app(argc, argv);

ctkPluginFrameworkLauncher::addSearchPath(QCoreApplication::applicationDirPath() + "/plugins");
bool success = ctkPluginFrameworkLauncher::start("org.commontk.eventadmin");
ctkPluginContext* context = ctkPluginFrameworkLauncher::getPluginContext();

QString path = QCoreApplication::applicationDirPath() + "/plugins";
QDirIterator itPlugin(path, QStringList() << "*.dll" << "*.so", QDir::Files);
while (itPlugin.hasNext()) {
	QString strPlugin = itPlugin.next();
	try {
		QSharedPointer<ctkPlugin> plugin = context->installPlugin(QUrl::fromLocalFile(strPlugin));
		plugin->start(ctkPlugin::START_TRANSIENT);
		qDebug() << "Plugin start ..." << strPlugin;
	}
	catch (const ctkPluginException& e) {
		qDebug() << "Failed to install plugin" << e.what();
		return -1;
	}
}

ctkServiceReference reference = context->getServiceReference<IMainWindow>();
if (reference) {
	IMainWindow* service = qobject_cast<IMainWindow*>(context->getService(reference));
	if (service != Q_NULLPTR) {
		service->init();
	}
}

ctkPluginFrameworkLauncher::stop();

Here is a snapshot of what occur, with this I believe it is a multiple thread issue. I would like to take some advice on how(or where) to use ctkPluginFrameworkLauncher::stop().

244643815-fd532edb-df33-45db-afe7-744ccff8fb29

If I comment out the code

//ctkPluginFrameworkLauncher::stop();
Here is a snapshot of what occur
屏幕截图 2024-01-02 152417

I hope you can give me some suggestions,Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant