loadDCPlugin(): never call exit() inside a library.

This commit is contained in:
Gerhard Hoffmann 2024-05-03 13:08:25 +02:00
parent e24022a612
commit d64b029a2d

View File

@ -52,7 +52,6 @@ hwinf *Update::loadDCPlugin(QDir const &plugInDir, QString const &fname) {
qCritical() << "in directory" << plugInDir.absolutePath();
qCritical() << "cannot load plugin" << pluginLoader.fileName();
qCritical() << pluginLoader.errorString();
exit(-1);
}
qCritical() << "loadDCPlugin() plugin directory:" << plugInDir.absolutePath();
@ -60,25 +59,20 @@ hwinf *Update::loadDCPlugin(QDir const &plugInDir, QString const &fname) {
if (!pluginLoader.isLoaded()) {
qCritical() << pluginLoader.errorString();
exit(-2);
}
QObject *plugin = pluginLoader.instance();
if (!plugin) {
qCritical() << "cannot start instance";
exit(-3);
}
if (! (hw = qobject_cast<hwinf *>(plugin))) {
qCritical() << "cannot cast plugin" << plugin << "to hwinf";
exit(-4);
}
} else {
qCritical() << pluginLibName << "does not exist";
exit(-5);
}
} else {
qCritical() << "plugins directory" << plugInDir.absolutePath()
<< "does not exist";
exit(-6);
}
return hw;
}