diff --git a/libsearch/pluginmanage/plugin-manager.cpp b/libsearch/pluginmanage/plugin-manager.cpp index b0f4611..522a249 100644 --- a/libsearch/pluginmanage/plugin-manager.cpp +++ b/libsearch/pluginmanage/plugin-manager.cpp @@ -37,11 +37,6 @@ PluginManager *PluginManager::getInstance() return global_instance; } -void PluginManager::setPluginEnableByName(const QString &pluginName, bool enable) -{ - m_hash.value(pluginName)->setEnable(enable); -} - PluginManager::PluginManager(QObject *parent) : QObject(parent) { QDir pluginsDir(PLUGIN_INSTALL_DIRS); @@ -73,12 +68,11 @@ PluginManager::PluginManager(QObject *parent) : QObject(parent) PluginInterface *piface = dynamic_cast(plugin); if (!piface) continue; - m_hash.insert(piface->name(), piface); switch (piface->pluginType()) { case PluginInterface::PluginType::SearchPlugin: { auto p = dynamic_cast(plugin); - if (!SearchPluginManager::getInstance()->registerExternalPlugin(p, pluginsDir.absoluteFilePath(fileName))) { - m_hash.erase(m_hash.find(piface->name())); + if(!SearchPluginManager::getInstance()->registerExternalPlugin(p, pluginsDir.absoluteFilePath(fileName))) { + delete p; } break; } @@ -96,6 +90,4 @@ PluginManager::PluginManager(QObject *parent) : QObject(parent) PluginManager::~PluginManager() { - m_hash.clear(); - SearchPluginManager::getInstance()->close(); } diff --git a/libsearch/pluginmanage/plugin-manager.h b/libsearch/pluginmanage/plugin-manager.h index 8ef4649..af1958a 100644 --- a/libsearch/pluginmanage/plugin-manager.h +++ b/libsearch/pluginmanage/plugin-manager.h @@ -41,16 +41,11 @@ public: Q_SIGNALS: void pluginStateChanged(const QString &pluginName, bool enable); -public Q_SLOTS: - void setPluginEnableByName(const QString &pluginName, bool enable); - private: explicit PluginManager(QObject *parent = nullptr); ~PluginManager(); - QHash m_hash; - }; } diff --git a/libsearch/pluginmanage/search-plugin-manager.cpp b/libsearch/pluginmanage/search-plugin-manager.cpp index 99896cd..6990591 100644 --- a/libsearch/pluginmanage/search-plugin-manager.cpp +++ b/libsearch/pluginmanage/search-plugin-manager.cpp @@ -58,6 +58,10 @@ bool SearchPluginManager::registerPlugin(UkuiSearch::SearchPluginIface *plugin) if (m_map.end() != m_map.find(plugin->name())) { qWarning() << "the plugin:" << plugin->name() << "has been registered."; + if (plugin) { + delete plugin; + plugin = nullptr; + } return res; } @@ -440,11 +444,6 @@ SearchPluginIface *SearchPluginManager::getPlugin(const QString &pluginId) return m_map[pluginId]; } -void SearchPluginManager::close() -{ - this->deleteLater(); -} - SearchPluginManager::~SearchPluginManager() { for (auto iter = m_map.begin(); iter != m_map.end();) { diff --git a/libsearch/pluginmanage/search-plugin-manager.h b/libsearch/pluginmanage/search-plugin-manager.h index c55e7dc..d441ffa 100644 --- a/libsearch/pluginmanage/search-plugin-manager.h +++ b/libsearch/pluginmanage/search-plugin-manager.h @@ -56,8 +56,6 @@ public: const QList getPluginIds(); SearchPluginIface *getPlugin(const QString &pluginId); - void close(); - private: explicit SearchPluginManager(QObject *parent = nullptr); ~SearchPluginManager();