QFactoryLoader: embed the Private class into the front-end
Simplifies the code and avoids unnecessary indirections. It's done in a quirky way with a d member with operator->() to mostly preserve Git history. Change-Id: I0989ef9b4cd7a620c891fffdb521d4280896d275 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
411a8332a7
commit
4c2d3b7a4c
@ -5,7 +5,6 @@
|
|||||||
#include "qfactoryloader_p.h"
|
#include "qfactoryloader_p.h"
|
||||||
|
|
||||||
#include "private/qcoreapplication_p.h"
|
#include "private/qcoreapplication_p.h"
|
||||||
#include "private/qduplicatetracker_p.h"
|
|
||||||
#include "private/qloggingregistry_p.h"
|
#include "private/qloggingregistry_p.h"
|
||||||
#include "qcborarray.h"
|
#include "qcborarray.h"
|
||||||
#include "qcbormap.h"
|
#include "qcbormap.h"
|
||||||
@ -16,20 +15,11 @@
|
|||||||
#include "qjsonarray.h"
|
#include "qjsonarray.h"
|
||||||
#include "qjsondocument.h"
|
#include "qjsondocument.h"
|
||||||
#include "qjsonobject.h"
|
#include "qjsonobject.h"
|
||||||
#include "qmutex.h"
|
|
||||||
#include "qplugin.h"
|
#include "qplugin.h"
|
||||||
#include "qplugin_p.h"
|
|
||||||
#include "qpluginloader.h"
|
#include "qpluginloader.h"
|
||||||
|
|
||||||
#if QT_CONFIG(library)
|
|
||||||
# include "qlibrary_p.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <qtcore_tracepoints_p.h>
|
#include <qtcore_tracepoints_p.h>
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
using namespace Qt::StringLiterals;
|
using namespace Qt::StringLiterals;
|
||||||
@ -247,28 +237,6 @@ QJsonObject QPluginParsedMetaData::toJson() const
|
|||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
class QFactoryLoaderPrivate
|
|
||||||
{
|
|
||||||
Q_DISABLE_COPY_MOVE(QFactoryLoaderPrivate)
|
|
||||||
public:
|
|
||||||
QFactoryLoaderPrivate() { }
|
|
||||||
QByteArray iid;
|
|
||||||
mutable QMutex mutex;
|
|
||||||
mutable QList<QtPluginInstanceFunction> usedStaticInstances;
|
|
||||||
#if QT_CONFIG(library)
|
|
||||||
~QFactoryLoaderPrivate();
|
|
||||||
QDuplicateTracker<QString> loadedPaths;
|
|
||||||
std::vector<QLibraryPrivate::UniquePtr> libraries;
|
|
||||||
mutable QList<bool> loadedLibraries;
|
|
||||||
std::map<QString, QLibraryPrivate*> keyMap;
|
|
||||||
QString suffix;
|
|
||||||
QString extraSearchPath;
|
|
||||||
Qt::CaseSensitivity cs;
|
|
||||||
|
|
||||||
void updateSinglePath(const QString &pluginDir);
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
#if QT_CONFIG(library)
|
#if QT_CONFIG(library)
|
||||||
|
|
||||||
Q_STATIC_LOGGING_CATEGORY_WITH_ENV_OVERRIDE(lcFactoryLoader, "QT_DEBUG_PLUGINS",
|
Q_STATIC_LOGGING_CATEGORY_WITH_ENV_OVERRIDE(lcFactoryLoader, "QT_DEBUG_PLUGINS",
|
||||||
@ -286,10 +254,7 @@ struct QFactoryLoaderGlobals
|
|||||||
|
|
||||||
Q_GLOBAL_STATIC(QFactoryLoaderGlobals, qt_factoryloader_global)
|
Q_GLOBAL_STATIC(QFactoryLoaderGlobals, qt_factoryloader_global)
|
||||||
|
|
||||||
QFactoryLoaderPrivate::~QFactoryLoaderPrivate()
|
inline void QFactoryLoader::Private::updateSinglePath(const QString &path)
|
||||||
= default;
|
|
||||||
|
|
||||||
inline void QFactoryLoaderPrivate::updateSinglePath(const QString &path)
|
|
||||||
{
|
{
|
||||||
struct LibraryReleaser {
|
struct LibraryReleaser {
|
||||||
void operator()(QLibraryPrivate *library)
|
void operator()(QLibraryPrivate *library)
|
||||||
@ -462,7 +427,6 @@ void QFactoryLoader::refreshAll()
|
|||||||
QFactoryLoader::QFactoryLoader(const char *iid,
|
QFactoryLoader::QFactoryLoader(const char *iid,
|
||||||
const QString &suffix,
|
const QString &suffix,
|
||||||
Qt::CaseSensitivity cs)
|
Qt::CaseSensitivity cs)
|
||||||
: d(new QFactoryLoaderPrivate)
|
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(suffix.startsWith(u'/'), "QFactoryLoader",
|
Q_ASSERT_X(suffix.startsWith(u'/'), "QFactoryLoader",
|
||||||
"For historical reasons, the suffix must start with '/' (and it can't be empty)");
|
"For historical reasons, the suffix must start with '/' (and it can't be empty)");
|
||||||
|
@ -20,19 +20,22 @@
|
|||||||
#ifndef QT_NO_QOBJECT
|
#ifndef QT_NO_QOBJECT
|
||||||
|
|
||||||
#include "QtCore/private/qplugin_p.h"
|
#include "QtCore/private/qplugin_p.h"
|
||||||
#include "QtCore/qcbormap.h"
|
#include "QtCore/private/qduplicatetracker_p.h"
|
||||||
#include "QtCore/qcborvalue.h"
|
|
||||||
#include "QtCore/qcoreapplication.h"
|
#include "QtCore/qcoreapplication.h"
|
||||||
#include "QtCore/qmap.h"
|
#include "QtCore/qmap.h"
|
||||||
|
#include "QtCore/qmutex.h"
|
||||||
#include "QtCore/qobject.h"
|
#include "QtCore/qobject.h"
|
||||||
#include "QtCore/qplugin.h"
|
#include "QtCore/qplugin.h"
|
||||||
|
|
||||||
|
#if QT_CONFIG(library)
|
||||||
|
# include "QtCore/private/qlibrary_p.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class QJsonObject;
|
class QJsonObject;
|
||||||
class QLibraryPrivate;
|
class QLibraryPrivate;
|
||||||
|
|
||||||
class QFactoryLoaderPrivate;
|
|
||||||
class Q_CORE_EXPORT QFactoryLoader
|
class Q_CORE_EXPORT QFactoryLoader
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(QFactoryLoader);
|
Q_DECLARE_TR_FUNCTIONS(QFactoryLoader);
|
||||||
@ -64,7 +67,25 @@ public:
|
|||||||
QObject *instance(int index) const;
|
QObject *instance(int index) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<QFactoryLoaderPrivate> d;
|
struct Private {
|
||||||
|
QByteArray iid;
|
||||||
|
mutable QMutex mutex;
|
||||||
|
mutable QList<QtPluginInstanceFunction> usedStaticInstances;
|
||||||
|
#if QT_CONFIG(library)
|
||||||
|
QDuplicateTracker<QString> loadedPaths;
|
||||||
|
std::vector<QLibraryPrivate::UniquePtr> libraries;
|
||||||
|
mutable QList<bool> loadedLibraries;
|
||||||
|
std::map<QString, QLibraryPrivate*> keyMap;
|
||||||
|
QString suffix;
|
||||||
|
QString extraSearchPath;
|
||||||
|
Qt::CaseSensitivity cs;
|
||||||
|
void updateSinglePath(const QString &pluginDir);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// for compat when we d was a pointer
|
||||||
|
auto operator->() { return this; }
|
||||||
|
auto operator->() const { return this; }
|
||||||
|
} d;
|
||||||
|
|
||||||
inline QObject *instanceHelper_locked(int index) const;
|
inline QObject *instanceHelper_locked(int index) const;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user