From 2d71d6163bf9bb3bbdc715a265209397d58c8c1c Mon Sep 17 00:00:00 2001 From: Johannes Lorenz Date: Fri, 15 Mar 2019 18:42:34 +0100 Subject: [PATCH] Rework after code reading * Fix possible segfault in `SubPluginFeatures::displayName` * Minor fixes --- include/Plugin.h | 6 +++--- src/core/Plugin.cpp | 4 ++-- src/core/PluginFactory.cpp | 23 +++++++++++------------ 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/include/Plugin.h b/include/Plugin.h index 48c5f90c7..31c83c4ba 100644 --- a/include/Plugin.h +++ b/include/Plugin.h @@ -202,19 +202,19 @@ public: virtual QString additionalFileExtensions(const Key&) const { - return nullptr; + return QString(); } virtual QString displayName(const Key& k) const { return k.isValid() ? k.desc->displayName - : k.name.toUtf8().data(); + : k.name; } virtual QString description(const Key& k) const { - return k.isValid() ? k.desc->description : ""; + return k.isValid() ? k.desc->description : QString(); } virtual const PixmapLoader* logo(const Key& k) const diff --git a/src/core/Plugin.cpp b/src/core/Plugin.cpp index 2975cf104..1562044f9 100644 --- a/src/core/Plugin.cpp +++ b/src/core/Plugin.cpp @@ -127,8 +127,8 @@ QString Plugin::Descriptor::SubPluginFeatures::Key::additionalFileExtensions() c return desc->subPluginFeatures // get from sub plugin ? desc->subPluginFeatures->additionalFileExtensions(*this) - // get from plugin - : nullptr; + // no sub plugin, so no *additional* file extensions + : QString(); } diff --git a/src/core/PluginFactory.cpp b/src/core/PluginFactory.cpp index f84227091..abf642122 100644 --- a/src/core/PluginFactory.cpp +++ b/src/core/PluginFactory.cpp @@ -180,10 +180,6 @@ void PluginFactory::discoverPlugins() continue; } } - else - { - //qDebug() << "Ignoring" << file.absoluteFilePath() << "(no lmms_plugin_main())"; - } if(pluginDescriptor) { @@ -199,15 +195,18 @@ void PluginFactory::discoverPlugins() const Plugin::Descriptor::SubPluginFeatures::Key* key = nullptr) { if(!supportedFileTypes.isNull()) - for (const QString& ext : supportedFileTypes.split(',')) { - //qDebug() << "Plugin " << info.name() << "supports" << ext; - PluginInfoAndKey infoAndKey; - infoAndKey.info = info; - infoAndKey.key = key - ? *key - : Plugin::Descriptor::SubPluginFeatures::Key(); - m_pluginByExt.insert(ext, infoAndKey); + for (const QString& ext : supportedFileTypes.split(',')) + { + //qDebug() << "Plugin " << info.name() + // << "supports" << ext; + PluginInfoAndKey infoAndKey; + infoAndKey.info = info; + infoAndKey.key = key + ? *key + : Plugin::Descriptor::SubPluginFeatures::Key(); + m_pluginByExt.insert(ext, infoAndKey); + } } };