Improve logging of issues during plugin loading

If the plugin could not be loaded the client calls qFatal
Make the loading warnings critical so they get printed before we crash
This commit is contained in:
Hannah von Reth 2020-03-18 12:26:15 +01:00 committed by Kevin Ottens
parent d63d4cdf62
commit 868b05f25b
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2

View file

@ -185,26 +185,26 @@ std::unique_ptr<Vfs> OCC::createVfsFromPlugin(Vfs::Mode mode)
auto pluginPath = pluginFileName("vfs", name);
if (!isVfsPluginAvailable(mode)) {
qCWarning(lcPlugin) << "Could not load plugin: not existant or bad metadata" << pluginPath;
qCCritical(lcPlugin) << "Could not load plugin: not existant or bad metadata" << pluginPath;
return nullptr;
}
QPluginLoader loader(pluginPath);
auto plugin = loader.instance();
if (!plugin) {
qCWarning(lcPlugin) << "Could not load plugin" << pluginPath << loader.errorString();
qCCritical(lcPlugin) << "Could not load plugin" << pluginPath << loader.errorString();
return nullptr;
}
auto factory = qobject_cast<PluginFactory *>(plugin);
if (!factory) {
qCWarning(lcPlugin) << "Plugin" << pluginPath << "does not implement PluginFactory";
qCCritical(lcPlugin) << "Plugin" << loader.fileName() << "does not implement PluginFactory";
return nullptr;
}
auto vfs = std::unique_ptr<Vfs>(qobject_cast<Vfs *>(factory->create(nullptr)));
if (!vfs) {
qCWarning(lcPlugin) << "Plugin" << pluginPath << "does not create a Vfs instance";
qCCritical(lcPlugin) << "Plugin" << loader.fileName() << "does not create a Vfs instance";
return nullptr;
}