From 72585ef3f1849c58ab4ba7a632f6fb9dbbfa1429 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 18 Jan 2018 14:44:59 +0100 Subject: [PATCH] ExtensionSystem: Remove type based getObjects() Since commit cc883023090030eb341a11c4d6634ca027f02c65, access to the typed lists is cheaper via the local pools, and subsequently all users of getObjects() have been adapted. As getObjects() is unused now, and the local pool pattern is preferred, having the function around is not needed anymore. If the provided functionality would ever be needed, user code can use allObjects() and manually filter. Change-Id: I1e9d8fa11da2ed0e68090cce1a25a3dd62c1aef6 Reviewed-by: Eike Ziller --- src/libs/extensionsystem/pluginmanager.cpp | 34 ++++------------------ src/libs/extensionsystem/pluginmanager.h | 25 ---------------- 2 files changed, 5 insertions(+), 54 deletions(-) diff --git a/src/libs/extensionsystem/pluginmanager.cpp b/src/libs/extensionsystem/pluginmanager.cpp index 0bbd5e780bc..66e52648cca 100644 --- a/src/libs/extensionsystem/pluginmanager.cpp +++ b/src/libs/extensionsystem/pluginmanager.cpp @@ -117,8 +117,8 @@ enum { debugLeaks = 0 }; \section1 Object Pool Plugins (and everybody else) can add objects to a common 'pool' that is located in the plugin manager. Objects in the pool must derive from QObject, there are no other - prerequisites. All objects of a specified type can be retrieved from the object pool - via the getObjects() and getObject() functions. + prerequisites. Objects can be retrieved from the object pool via the getObject() + and getObjectByName() functions. Whenever the state of the object pool changes a corresponding signal is emitted by the plugin manager. @@ -132,8 +132,8 @@ enum { debugLeaks = 0 }; MyMimeTypeHandler *handler = new MyMimeTypeHandler(); PluginManager::instance()->addObject(handler); // In plugin A: - QList mimeHandlers = - PluginManager::getObjects(); + MimeTypeHandler *mimeHandler = + PluginManager::getObject(); \endcode @@ -249,29 +249,6 @@ enum { debugLeaks = 0 }; \sa addObject() */ -/*! - \fn QList PluginManager::getObjects() - - Retrieves all objects of a given type from the object pool. - - This function uses \c qobject_cast to determine the type of an object. - - \sa addObject() -*/ - -/*! - \fn QList PluginManager::getObjects(Predicate predicate) - - Retrieves all objects of a given type from the object pool that - match the \a predicate. - - This function uses \c qobject_cast to determine the type of an object. - The predicate should be a unary function taking a T* parameter and - returning a bool. - - \sa addObject() -*/ - using namespace Utils; @@ -319,7 +296,7 @@ PluginManager::~PluginManager() \sa PluginManager::removeObject() \sa PluginManager::getObject() - \sa PluginManager::getObjects() + \sa PluginManager::getObjectByName() */ void PluginManager::addObject(QObject *obj) { @@ -341,7 +318,6 @@ void PluginManager::removeObject(QObject *obj) Usually, clients do not need to call this function. \sa PluginManager::getObject() - \sa PluginManager::getObjects() */ QList PluginManager::allObjects() { diff --git a/src/libs/extensionsystem/pluginmanager.h b/src/libs/extensionsystem/pluginmanager.h index b2ff7378eef..11cf0ae62cd 100644 --- a/src/libs/extensionsystem/pluginmanager.h +++ b/src/libs/extensionsystem/pluginmanager.h @@ -57,31 +57,6 @@ public: static void removeObject(QObject *obj); static QList allObjects(); static QReadWriteLock *listLock(); - template static QList getObjects() - { - QReadLocker lock(listLock()); - QList results; - QList all = allObjects(); - foreach (QObject *obj, all) { - T *result = qobject_cast(obj); - if (result) - results += result; - } - return results; - } - template - static QList getObjects(Predicate predicate) - { - QReadLocker lock(listLock()); - QList results; - QList all = allObjects(); - foreach (QObject *obj, all) { - T *result = qobject_cast(obj); - if (result && predicate(result)) - results += result; - } - return results; - } // This is useful for soft dependencies using pure interfaces. template static T *getObject()