Commit cc883023 authored by hjk's avatar hjk

De-emphasize PluginManager::getObjects<Type>()

... by additionally keeping local (currently non-owning) pools per
"interesting" type.

Current situation:
  - The global object pool does not scale well for looking up
    objects, as iteration plus qobject_cast typically iterates
    over all pooled objects.
  - User code that can use typed results from the object
    pool need to have access to the full type definition anyway,
    i.e.  depend on the plugin of the target class anyway.

The patch here solves the scaling problem is to have local
type-specific pools to which objects register in their
constructors and deregister in their destructors.

This patch here does *not* change the ownership model of the
pooled objects, however, it opens the possibility to change
the ownership model per type (e.g. by not putting things into
the global pool at all anymore and make the local pool 'owning')
and the intent is to handle that in later patchs.

Even without the follow-up patches this here is a performance
improvement for the cases that access the local pools instead
the global one, i.e. "practically all".

Change-Id: Ib11a42df2c4ecf5e1155534730083a520dd1995b
Reviewed-by: Eike Ziller's avatarEike Ziller <eike.ziller@qt.io>
Reviewed-by: Christian Kandeler's avatarChristian Kandeler <christian.kandeler@qt.io>
parent 32762e27
...@@ -82,6 +82,8 @@ public: ...@@ -82,6 +82,8 @@ public:
} }
return results; return results;
} }
// This is useful for soft dependencies using pure interfaces.
template <typename T> static T *getObject() template <typename T> static T *getObject()
{ {
QReadLocker lock(listLock()); QReadLocker lock(listLock());
......
...@@ -204,6 +204,24 @@ QString PropertyInfo::toString() const ...@@ -204,6 +204,24 @@ QString PropertyInfo::toString() const
return list.join('|'); return list.join('|');
} }
static QList<CustomImportsProvider *> g_customImportProviders;
CustomImportsProvider::CustomImportsProvider(QObject *parent)
: QObject(parent)
{
g_customImportProviders.append(this);
}
CustomImportsProvider::~CustomImportsProvider()
{
g_customImportProviders.removeOne(this);
}
const QList<CustomImportsProvider *> CustomImportsProvider::allProviders()
{
return g_customImportProviders;
}
} // namespace QmlJS } // namespace QmlJS
CppComponentValue::CppComponentValue(FakeMetaObject::ConstPtr metaObject, const QString &className, CppComponentValue::CppComponentValue(FakeMetaObject::ConstPtr metaObject, const QString &className,
......
...@@ -1127,8 +1127,11 @@ class QMLJS_EXPORT CustomImportsProvider : public QObject ...@@ -1127,8 +1127,11 @@ class QMLJS_EXPORT CustomImportsProvider : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CustomImportsProvider(QObject *parent = 0) : QObject(parent) {} explicit CustomImportsProvider(QObject *parent = nullptr);
virtual ~CustomImportsProvider() {} virtual ~CustomImportsProvider();
static const QList<CustomImportsProvider *> allProviders();
virtual QList<Import> imports(ValueOwner *valueOwner, const Document *context) const = 0; virtual QList<Import> imports(ValueOwner *valueOwner, const Document *context) const = 0;
}; };
......
...@@ -33,8 +33,6 @@ ...@@ -33,8 +33,6 @@
#include "qmljsqrcparser.h" #include "qmljsqrcparser.h"
#include "qmljsconstants.h" #include "qmljsconstants.h"
#include <extensionsystem/pluginmanager.h>
#include <QDir> #include <QDir>
using namespace LanguageUtils; using namespace LanguageUtils;
...@@ -212,12 +210,9 @@ Context::ImportsPerDocument LinkPrivate::linkImports() ...@@ -212,12 +210,9 @@ Context::ImportsPerDocument LinkPrivate::linkImports()
Imports *imports = new Imports(valueOwner); Imports *imports = new Imports(valueOwner);
// Add custom imports for the opened document // Add custom imports for the opened document
if (ExtensionSystem::PluginManager::instance()) { for (const auto &provider : CustomImportsProvider::allProviders())
auto providers = ExtensionSystem::PluginManager::getObjects<CustomImportsProvider>(); foreach (const auto &import, provider->imports(valueOwner, document.data()))
foreach (const auto &provider, providers) importCache.insert(ImportCacheKey(import.info), import);
foreach (const auto &import, provider->imports(valueOwner, document.data()))
importCache.insert(ImportCacheKey(import.info), import);
}
populateImportedTypes(imports, document); populateImportedTypes(imports, document);
importsPerDocument.insert(document.data(), QSharedPointer<Imports>(imports)); importsPerDocument.insert(document.data(), QSharedPointer<Imports>(imports));
......
...@@ -41,8 +41,6 @@ ...@@ -41,8 +41,6 @@
#include <coreplugin/messagemanager.h> #include <coreplugin/messagemanager.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/buildconfiguration.h> #include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorer.h>
...@@ -92,6 +90,18 @@ static bool openXmlFile(QDomDocument &doc, const Utils::FileName &fileName); ...@@ -92,6 +90,18 @@ static bool openXmlFile(QDomDocument &doc, const Utils::FileName &fileName);
static bool openManifest(ProjectExplorer::Target *target, QDomDocument &doc); static bool openManifest(ProjectExplorer::Target *target, QDomDocument &doc);
static int parseMinSdk(const QDomElement &manifestElem); static int parseMinSdk(const QDomElement &manifestElem);
static QList<AndroidQtSupport *> g_androidQtSupportProviders;
AndroidQtSupport::AndroidQtSupport()
{
g_androidQtSupportProviders.append(this);
}
AndroidQtSupport::~AndroidQtSupport()
{
g_androidQtSupportProviders.removeOne(this);
}
bool AndroidManager::supportsAndroid(const ProjectExplorer::Kit *kit) bool AndroidManager::supportsAndroid(const ProjectExplorer::Kit *kit)
{ {
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit); QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit);
...@@ -457,8 +467,7 @@ bool AndroidManager::checkForQt51Files(Utils::FileName fileName) ...@@ -457,8 +467,7 @@ bool AndroidManager::checkForQt51Files(Utils::FileName fileName)
AndroidQtSupport *AndroidManager::androidQtSupport(ProjectExplorer::Target *target) AndroidQtSupport *AndroidManager::androidQtSupport(ProjectExplorer::Target *target)
{ {
QList<AndroidQtSupport *> providerList = ExtensionSystem::PluginManager::getObjects<AndroidQtSupport>(); for (AndroidQtSupport *provider : g_androidQtSupportProviders) {
foreach (AndroidQtSupport *provider, providerList) {
if (provider->canHandle(target)) if (provider->canHandle(target))
return provider; return provider;
} }
......
...@@ -45,6 +45,10 @@ class ANDROID_EXPORT AndroidQtSupport : public QObject ...@@ -45,6 +45,10 @@ class ANDROID_EXPORT AndroidQtSupport : public QObject
{ {
Q_OBJECT Q_OBJECT
protected:
AndroidQtSupport();
~AndroidQtSupport();
public: public:
enum BuildType { enum BuildType {
DebugBuild, DebugBuild,
...@@ -52,7 +56,6 @@ public: ...@@ -52,7 +56,6 @@ public:
ReleaseBuildSigned ReleaseBuildSigned
}; };
public:
virtual bool canHandle(const ProjectExplorer::Target *target) const = 0; virtual bool canHandle(const ProjectExplorer::Target *target) const = 0;
virtual QStringList soLibSearchPath(const ProjectExplorer::Target *target) const = 0; virtual QStringList soLibSearchPath(const ProjectExplorer::Target *target) const = 0;
virtual QStringList androidExtraLibs(const ProjectExplorer::Target *target) const = 0; virtual QStringList androidExtraLibs(const ProjectExplorer::Target *target) const = 0;
......
...@@ -28,14 +28,24 @@ ...@@ -28,14 +28,24 @@
#include "basefilewizardfactory.h" #include "basefilewizardfactory.h"
#include "ifilewizardextension.h" #include "ifilewizardextension.h"
#include <extensionsystem/pluginmanager.h>
#include <QMessageBox> #include <QMessageBox>
using namespace Utils; using namespace Utils;
namespace Core { namespace Core {
static QList<IFileWizardExtension *> g_fileWizardExtensions;
IFileWizardExtension::IFileWizardExtension()
{
g_fileWizardExtensions.append(this);
}
IFileWizardExtension::~IFileWizardExtension()
{
g_fileWizardExtensions.removeOne(this);
}
BaseFileWizard::BaseFileWizard(const BaseFileWizardFactory *factory, BaseFileWizard::BaseFileWizard(const BaseFileWizardFactory *factory,
const QVariantMap &extraValues, const QVariantMap &extraValues,
QWidget *parent) : QWidget *parent) :
...@@ -43,19 +53,8 @@ BaseFileWizard::BaseFileWizard(const BaseFileWizardFactory *factory, ...@@ -43,19 +53,8 @@ BaseFileWizard::BaseFileWizard(const BaseFileWizardFactory *factory,
m_extraValues(extraValues), m_extraValues(extraValues),
m_factory(factory) m_factory(factory)
{ {
// Compile extension pages, purge out unused ones for (IFileWizardExtension *extension : g_fileWizardExtensions)
QList<IFileWizardExtension *> extensionList m_extensionPages += extension->extensionPages(factory);
= ExtensionSystem::PluginManager::getObjects<IFileWizardExtension>();
for (auto it = extensionList.begin(); it != extensionList.end(); ) {
const QList<QWizardPage *> extensionPages = (*it)->extensionPages(factory);
if (extensionPages.empty()) {
it = extensionList.erase(it);
} else {
m_extensionPages += extensionPages;
++it;
}
}
if (!m_extensionPages.empty()) if (!m_extensionPages.empty())
m_firstExtensionPage = m_extensionPages.front(); m_firstExtensionPage = m_extensionPages.front();
...@@ -67,9 +66,7 @@ void BaseFileWizard::initializePage(int id) ...@@ -67,9 +66,7 @@ void BaseFileWizard::initializePage(int id)
if (page(id) == m_firstExtensionPage) { if (page(id) == m_firstExtensionPage) {
generateFileList(); generateFileList();
QList<IFileWizardExtension *> extensionList for (IFileWizardExtension *ex : g_fileWizardExtensions)
= ExtensionSystem::PluginManager::getObjects<IFileWizardExtension>();
foreach (IFileWizardExtension *ex, extensionList)
ex->firstExtensionPageShown(m_files, m_extraValues); ex->firstExtensionPageShown(m_files, m_extraValues);
} }
} }
...@@ -99,9 +96,7 @@ void BaseFileWizard::accept() ...@@ -99,9 +96,7 @@ void BaseFileWizard::accept()
break; break;
} }
QList<IFileWizardExtension *> extensionList for (IFileWizardExtension *ex : g_fileWizardExtensions) {
= ExtensionSystem::PluginManager::getObjects<IFileWizardExtension>();
foreach (IFileWizardExtension *ex, extensionList) {
for (int i = 0; i < m_files.count(); i++) { for (int i = 0; i < m_files.count(); i++) {
ex->applyCodeStyle(&m_files[i]); ex->applyCodeStyle(&m_files[i]);
} }
...@@ -116,7 +111,7 @@ void BaseFileWizard::accept() ...@@ -116,7 +111,7 @@ void BaseFileWizard::accept()
bool removeOpenProjectAttribute = false; bool removeOpenProjectAttribute = false;
// Run the extensions // Run the extensions
foreach (IFileWizardExtension *ex, extensionList) { for (IFileWizardExtension *ex : g_fileWizardExtensions) {
bool remove; bool remove;
if (!ex->processFiles(m_files, &remove, &errorMessage)) { if (!ex->processFiles(m_files, &remove, &errorMessage)) {
if (!errorMessage.isEmpty()) if (!errorMessage.isEmpty())
......
...@@ -135,6 +135,7 @@ QIcon Core::IOptionsPage::categoryIcon() const ...@@ -135,6 +135,7 @@ QIcon Core::IOptionsPage::categoryIcon() const
Sets \a categoryIcon as the category icon of the options page. Sets \a categoryIcon as the category icon of the options page.
*/ */
static QList<Core::IOptionsPage *> g_optionsPages;
/*! /*!
Constructs an options page with the given \a parent. Constructs an options page with the given \a parent.
...@@ -143,7 +144,7 @@ Core::IOptionsPage::IOptionsPage(QObject *parent) ...@@ -143,7 +144,7 @@ Core::IOptionsPage::IOptionsPage(QObject *parent)
: QObject(parent), : QObject(parent),
m_keywordsInitialized(false) m_keywordsInitialized(false)
{ {
g_optionsPages.append(this);
} }
/*! /*!
...@@ -151,6 +152,12 @@ Core::IOptionsPage::IOptionsPage(QObject *parent) ...@@ -151,6 +152,12 @@ Core::IOptionsPage::IOptionsPage(QObject *parent)
*/ */
Core::IOptionsPage::~IOptionsPage() Core::IOptionsPage::~IOptionsPage()
{ {
g_optionsPages.removeOne(this);
}
const QList<Core::IOptionsPage *> Core::IOptionsPage::allOptionsPages()
{
return g_optionsPages;
} }
/*! /*!
...@@ -183,6 +190,24 @@ bool Core::IOptionsPage::matches(const QString &searchKeyWord) const ...@@ -183,6 +190,24 @@ bool Core::IOptionsPage::matches(const QString &searchKeyWord) const
return false; return false;
} }
static QList<Core::IOptionsPageProvider *> g_optionsPagesProviders;
Core::IOptionsPageProvider::IOptionsPageProvider(QObject *parent)
: QObject(parent)
{
g_optionsPagesProviders.append(this);
}
Core::IOptionsPageProvider::~IOptionsPageProvider()
{
g_optionsPagesProviders.removeOne(this);
}
const QList<Core::IOptionsPageProvider *> Core::IOptionsPageProvider::allOptionsPagesProviders()
{
return g_optionsPagesProviders;
}
QIcon Core::IOptionsPageProvider::categoryIcon() const QIcon Core::IOptionsPageProvider::categoryIcon() const
{ {
return QIcon(m_categoryIcon); return QIcon(m_categoryIcon);
......
...@@ -47,6 +47,8 @@ public: ...@@ -47,6 +47,8 @@ public:
IOptionsPage(QObject *parent = 0); IOptionsPage(QObject *parent = 0);
virtual ~IOptionsPage(); virtual ~IOptionsPage();
static const QList<IOptionsPage *> allOptionsPages();
Id id() const { return m_id; } Id id() const { return m_id; }
QString displayName() const { return m_displayName; } QString displayName() const { return m_displayName; }
Id category() const { return m_category; } Id category() const { return m_category; }
...@@ -88,7 +90,10 @@ class CORE_EXPORT IOptionsPageProvider : public QObject ...@@ -88,7 +90,10 @@ class CORE_EXPORT IOptionsPageProvider : public QObject
Q_OBJECT Q_OBJECT
public: public:
IOptionsPageProvider(QObject *parent = 0) : QObject(parent) {} IOptionsPageProvider(QObject *parent = nullptr);
~IOptionsPageProvider();
static const QList<IOptionsPageProvider *> allOptionsPagesProviders();
Id category() const { return m_category; } Id category() const { return m_category; }
QString displayCategory() const { return m_displayCategory; } QString displayCategory() const { return m_displayCategory; }
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/fancylineedit.h> #include <utils/fancylineedit.h>
...@@ -69,7 +68,7 @@ bool optionsPageLessThan(const IOptionsPage *p1, const IOptionsPage *p2) ...@@ -69,7 +68,7 @@ bool optionsPageLessThan(const IOptionsPage *p1, const IOptionsPage *p2)
static inline QList<IOptionsPage*> sortedOptionsPages() static inline QList<IOptionsPage*> sortedOptionsPages()
{ {
QList<IOptionsPage*> rc = ExtensionSystem::PluginManager::getObjects<IOptionsPage>(); QList<IOptionsPage*> rc = IOptionsPage::allOptionsPages();
std::stable_sort(rc.begin(), rc.end(), optionsPageLessThan); std::stable_sort(rc.begin(), rc.end(), optionsPageLessThan);
return rc; return rc;
} }
...@@ -414,8 +413,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) : ...@@ -414,8 +413,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
else else
setWindowTitle(tr("Options")); setWindowTitle(tr("Options"));
m_model->setPages(m_pages, m_model->setPages(m_pages, IOptionsPageProvider::allOptionsPagesProviders());
ExtensionSystem::PluginManager::getObjects<IOptionsPageProvider>());
m_proxyModel->setSourceModel(m_model); m_proxyModel->setSourceModel(m_model);
m_proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); m_proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
......
...@@ -25,13 +25,23 @@ ...@@ -25,13 +25,23 @@
#include "diffservice.h" #include "diffservice.h"
#include <extensionsystem/pluginmanager.h>
namespace Core { namespace Core {
static DiffService *g_instance = nullptr;
DiffService::DiffService()
{
g_instance = this;
}
DiffService::~DiffService()
{
g_instance = nullptr;
}
DiffService *DiffService::instance() DiffService *DiffService::instance()
{ {
return ExtensionSystem::PluginManager::getObject<DiffService>(); return g_instance;
} }
} // Core } // Core
...@@ -38,7 +38,8 @@ class CORE_EXPORT DiffService ...@@ -38,7 +38,8 @@ class CORE_EXPORT DiffService
public: public:
static DiffService *instance(); static DiffService *instance();
virtual ~DiffService() {} DiffService();
virtual ~DiffService();
virtual void diffFiles(const QString &leftFileName, const QString &rightFileName) = 0; virtual void diffFiles(const QString &leftFileName, const QString &rightFileName) = 0;
virtual void diffModifiedFiles(const QStringList &fileNames) = 0; virtual void diffModifiedFiles(const QStringList &fileNames) = 0;
......
...@@ -711,24 +711,26 @@ bool DocumentManager::saveDocument(IDocument *document, const QString &fileName, ...@@ -711,24 +711,26 @@ bool DocumentManager::saveDocument(IDocument *document, const QString &fileName,
return ret; return ret;
} }
template<typename FactoryType> QString DocumentManager::allDocumentFactoryFiltersString(QString *allFilesFilter = 0)
QSet<QString> filterStrings()
{ {
QSet<QString> filters; QSet<QString> uniqueFilters;
for (FactoryType *factory : ExtensionSystem::PluginManager::getObjects<FactoryType>()) {
for (IEditorFactory *factory : IEditorFactory::allEditorFactories()) {
for (const QString &mt : factory->mimeTypes()) { for (const QString &mt : factory->mimeTypes()) {
const QString filter = mimeTypeForName(mt).filterString(); const QString filter = mimeTypeForName(mt).filterString();
if (!filter.isEmpty()) if (!filter.isEmpty())
filters.insert(filter); uniqueFilters.insert(filter);
}
}
for (IDocumentFactory *factory : IDocumentFactory::allDocumentFactories()) {
for (const QString &mt : factory->mimeTypes()) {
const QString filter = mimeTypeForName(mt).filterString();
if (!filter.isEmpty())
uniqueFilters.insert(filter);
} }
} }
return filters;
}
QString DocumentManager::allDocumentFactoryFiltersString(QString *allFilesFilter = 0)
{
const QSet<QString> uniqueFilters = filterStrings<IDocumentFactory>()
+ filterStrings<IEditorFactory>();
QStringList filters = uniqueFilters.toList(); QStringList filters = uniqueFilters.toList();
filters.sort(); filters.sort();
const QString allFiles = Utils::allFilesFilterString(); const QString allFiles = Utils::allFilesFilterString();
......
...@@ -186,17 +186,6 @@ static void setFocusToEditorViewAndUnmaximizePanes(EditorView *view) ...@@ -186,17 +186,6 @@ static void setFocusToEditorViewAndUnmaximizePanes(EditorView *view)
} }
} }
/* For something that has a 'QString id' (IEditorFactory
* or IExternalEditor), find the one matching a id. */
template <class EditorFactoryLike>
EditorFactoryLike *findById(Id id)
{
return ExtensionSystem::PluginManager::getObject<EditorFactoryLike>(
[&id](EditorFactoryLike *efl) {
return id == efl->id();
});
}
EditorManagerPrivate::EditorManagerPrivate(QObject *parent) : EditorManagerPrivate::EditorManagerPrivate(QObject *parent) :
QObject(parent), QObject(parent),
m_revertToSavedAction(new QAction(EditorManager::tr("Revert to Saved"), this)), m_revertToSavedAction(new QAction(EditorManager::tr("Revert to Saved"), this)),
...@@ -606,7 +595,9 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const QString &fileN ...@@ -606,7 +595,9 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const QString &fileN
return 0; return 0;
} }
if (editorId.isValid()) { if (editorId.isValid()) {
if (IEditorFactory *factory = findById<IEditorFactory>(editorId)) { IEditorFactory *factory = Utils::findOrDefault(IEditorFactory::allEditorFactories(),
Utils::equal(&IEditorFactory::id, editorId));
if (factory) {
factories.removeOne(factory); factories.removeOne(factory);
factories.push_front(factory); factories.push_front(factory);
} }
...@@ -1139,7 +1130,9 @@ EditorManager::EditorFactoryList EditorManagerPrivate::findFactories(Id editorId ...@@ -1139,7 +1130,9 @@ EditorManager::EditorFactoryList EditorManagerPrivate::findFactories(Id editorId
factories = EditorManager::editorFactories(mimeType, false); factories = EditorManager::editorFactories(mimeType, false);
} else { } else {
// Find by editor id // Find by editor id
if (IEditorFactory *factory = findById<IEditorFactory>(editorId)) IEditorFactory *factory = Utils::findOrDefault(IEditorFactory::allEditorFactories(),
Utils::equal(&IEditorFactory::id, editorId));
if (factory)
factories.push_back(factory); factories.push_back(factory);
} }
if (factories.empty()) { if (factories.empty()) {
...@@ -2606,7 +2599,7 @@ EditorManager::EditorFactoryList ...@@ -2606,7 +2599,7 @@ EditorManager::EditorFactoryList
EditorManager::editorFactories(const Utils::MimeType &mimeType, bool bestMatchOnly) EditorManager::editorFactories(const Utils::MimeType &mimeType, bool bestMatchOnly)
{ {
EditorFactoryList rc; EditorFactoryList rc;
const EditorFactoryList allFactories = ExtensionSystem::PluginManager::getObjects<IEditorFactory>(); const EditorFactoryList allFactories = IEditorFactory::allEditorFactories();
mimeTypeFactoryLookup(mimeType, allFactories, bestMatchOnly, &rc); mimeTypeFactoryLookup(mimeType, allFactories, bestMatchOnly, &rc);
if (debugEditorManager) if (debugEditorManager)
qDebug() << Q_FUNC_INFO << mimeType.name() << " returns " << rc; qDebug() << Q_FUNC_INFO << mimeType.name() << " returns " << rc;
...@@ -2617,7 +2610,7 @@ EditorManager::ExternalEditorList ...@@ -2617,7 +2610,7 @@ EditorManager::ExternalEditorList
EditorManager::externalEditors(const Utils::MimeType &mimeType, bool bestMatchOnly) EditorManager::externalEditors(const Utils::MimeType &mimeType, bool bestMatchOnly)
{ {
ExternalEditorList rc; ExternalEditorList rc;
const ExternalEditorList allEditors = ExtensionSystem::PluginManager::getObjects<IExternalEditor>(); const ExternalEditorList allEditors = IExternalEditor::allExternalEditors();
mimeTypeFactoryLookup(mimeType, allEditors, bestMatchOnly, &rc); mimeTypeFactoryLookup(mimeType, allEditors, bestMatchOnly, &rc);
if (debugEditorManager) if (debugEditorManager)
qDebug() << Q_FUNC_INFO << mimeType.name() << " returns " << rc; qDebug() << Q_FUNC_INFO << mimeType.name() << " returns " << rc;
...@@ -2692,7 +2685,8 @@ bool EditorManager::isAutoSaveFile(const QString &fileName) ...@@ -2692,7 +2685,8 @@ bool EditorManager::isAutoSaveFile(const QString &fileName)
bool EditorManager::openExternalEditor(const QString &fileName, Id editorId) bool EditorManager::openExternalEditor(const QString &fileName, Id editorId)
{ {
IExternalEditor *ee = findById<IExternalEditor>(editorId); IExternalEditor *ee = Utils::findOrDefault(IExternalEditor::allExternalEditors(),
Utils::equal(&IExternalEditor::id, editorId));
if (!ee) if (!ee)
return false; return false;
QString errorMessage; QString errorMessage;
......
...@@ -27,9 +27,24 @@ ...@@ -27,9 +27,24 @@
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
Core::IEditorFactory::IEditorFactory(QObject *parent) namespace Core {
static QList<IEditorFactory *> g_editorFactories;
IEditorFactory::IEditorFactory(QObject *parent)
: QObject(parent) : QObject(parent)
{ {
g_editorFactories.append(this);
}
IEditorFactory::~IEditorFactory()
{
g_editorFactories.removeOne(this);
}
const QList<IEditorFactory *> IEditorFactory::allEditorFactories()
{
return g_editorFactories;
} }
} // Core
...@@ -40,7 +40,11 @@ class CORE_EXPORT IEditorFactory : public QObject ...@@ -40,7 +40,11 @@ class CORE_EXPORT IEditorFactory : public QObject
Q_OBJECT Q_OBJECT
public: public:
IEditorFactory(QObject *parent = 0); IEditorFactory(QObject *parent = nullptr);
~IEditorFactory();
static const QList<IEditorFactory *> allEditorFactories();
QString displayName() const { return m_displayName; }