diff options
author | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-06-19 13:29:55 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-08-18 19:59:46 +0000 |
commit | 6c76fdc7616ac3b62c5750600bd6d5985dbceb20 (patch) | |
tree | 5f8ec6d8b0b444d07d9fe3780acf77996157c890 /src/corelib/plugin/qfactoryloader.cpp | |
parent | 1f437e7540cbdfca8adcad0b69ae26237846ab23 (diff) |
Allow loading of static plugins if QT_NO_LIBRARY is set.
We keep two symbols from QPluginLoader defined, even if QT_NO_LIBRARY
is set in order to be able to locate static plugins. This doesn't
constitute any loading of shared libraries or plugins from external
files at runtime.
Using these symbols we can enable most of QFactoryLoader even if
QT_NO_LIBRARY is set. Only update(), refreshAll(), library() and
the dtor make no sense then. This way QGenericPlugin also becomes
useful with QT_NO_LIBRARY.
Task-number: QTBUG-3045
Change-Id: Ib7842ce5799e8e2caa46431d95fddd1adda0fc41
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/plugin/qfactoryloader.cpp')
-rw-r--r-- | src/corelib/plugin/qfactoryloader.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index daecf0d3b0..f7545b5bcb 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -33,7 +33,7 @@ #include "qfactoryloader_p.h" -#ifndef QT_NO_LIBRARY +#ifndef QT_NO_QOBJECT #include "qfactoryinterface.h" #include "qmap.h" #include <qdir.h> @@ -66,6 +66,7 @@ class QFactoryLoaderPrivate : public QObjectPrivate public: QFactoryLoaderPrivate(){} QByteArray iid; +#ifndef QT_NO_LIBRARY ~QFactoryLoaderPrivate(); mutable QMutex mutex; QList<QLibraryPrivate*> libraryList; @@ -73,8 +74,11 @@ public: QString suffix; Qt::CaseSensitivity cs; QStringList loadedPaths; +#endif }; +#ifndef QT_NO_LIBRARY + Q_GLOBAL_STATIC(QList<QFactoryLoader *>, qt_factory_loaders) Q_GLOBAL_STATIC_WITH_ARGS(QMutex, qt_factoryloader_mutex, (QMutex::Recursive)) @@ -226,6 +230,8 @@ void QFactoryLoader::refreshAll() } } +#endif // QT_NO_LIBRARY + QFactoryLoader::QFactoryLoader(const char *iid, const QString &suffix, Qt::CaseSensitivity cs) @@ -234,21 +240,28 @@ QFactoryLoader::QFactoryLoader(const char *iid, moveToThread(QCoreApplicationPrivate::mainThread()); Q_D(QFactoryLoader); d->iid = iid; +#ifndef QT_NO_LIBRARY d->cs = cs; d->suffix = suffix; QMutexLocker locker(qt_factoryloader_mutex()); update(); qt_factory_loaders()->append(this); +#else + Q_UNUSED(suffix); + Q_UNUSED(cs); +#endif } QList<QJsonObject> QFactoryLoader::metaData() const { Q_D(const QFactoryLoader); QList<QJsonObject> metaData; +#ifndef QT_NO_LIBRARY QMutexLocker locker(&d->mutex); for (int i = 0; i < d->libraryList.size(); ++i) metaData.append(d->libraryList.at(i)->metaData); +#endif foreach (const QStaticPlugin &plugin, QPluginLoader::staticPlugins()) { const QJsonObject object = plugin.metaData(); @@ -265,6 +278,7 @@ QObject *QFactoryLoader::instance(int index) const if (index < 0) return 0; +#ifndef QT_NO_LIBRARY if (index < d->libraryList.size()) { QLibraryPrivate *library = d->libraryList.at(index); if (library->instance || library->loadPlugin()) { @@ -280,6 +294,7 @@ QObject *QFactoryLoader::instance(int index) const return 0; } index -= d->libraryList.size(); +#endif QVector<QStaticPlugin> staticPlugins = QPluginLoader::staticPlugins(); for (int i = 0; i < staticPlugins.count(); ++i) { @@ -330,4 +345,4 @@ int QFactoryLoader::indexOf(const QString &needle) const QT_END_NAMESPACE -#endif // QT_NO_LIBRARY +#endif // QT_NO_QOBJECT |