Don't call exit(), but return nullptr.

This commit is contained in:
Gerhard Hoffmann 2024-05-08 16:06:14 +02:00
parent b31588bfab
commit 696db7de39

View File

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