Drop most "#ifndef QT_NO_LIBRARY"

As we can load plugins without QLibrary now, we don't have to #ifdef
out the code that does so anymore.

Change-Id: I1dc20216830a882dbd5a1b431183407e6b19c837
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Ulf Hermann 2016-01-06 12:18:40 +01:00
parent 21861e6fd1
commit 4fb7eb0da7
17 changed files with 33 additions and 106 deletions

View File

@ -465,12 +465,10 @@ QAccessibleInterface::~QAccessibleInterface()
/* accessible widgets plugin discovery stuff */
#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
(QAccessibleFactoryInterface_iid, QLatin1String("/accessible")))
typedef QHash<QString, QAccessiblePlugin*> QAccessiblePluginsHash;
Q_GLOBAL_STATIC(QAccessiblePluginsHash, qAccessiblePlugins)
#endif
// FIXME turn this into one global static struct
Q_GLOBAL_STATIC(QList<QAccessible::InterfaceFactory>, qAccessibleFactories)
@ -691,7 +689,6 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
return iface;
}
}
#ifndef QT_NO_LIBRARY
// Find a QAccessiblePlugin (factory) for the class name. If there's
// no entry in the cache try to create it using the plugin loader.
if (!qAccessiblePlugins()->contains(cn)) {
@ -713,7 +710,6 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
}
return result;
}
#endif
mo = mo->superClass();
}

View File

@ -50,10 +50,8 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_ACCESSIBILITY
/* accessiblebridge plugin discovery stuff */
#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, bridgeloader,
(QAccessibleBridgeFactoryInterface_iid, QLatin1String("/accessiblebridge")))
#endif
Q_GLOBAL_STATIC(QVector<QAccessibleBridge *>, bridges)
@ -112,7 +110,6 @@ void QPlatformAccessibility::initialize()
return;
isInit = true; // ### not atomic
#ifndef QT_NO_LIBRARY
typedef QMultiMap<int, QString> PluginKeyMap;
typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator;
@ -129,7 +126,6 @@ void QPlatformAccessibility::initialize()
if (QAccessibleBridge *bridge = factory->create(it.value()))
bridges()->append(bridge);
}
#endif
}
void QPlatformAccessibility::cleanup()

View File

@ -529,7 +529,6 @@ void QPixmapIconEngine::virtual_hook(int id, void *data)
}
}
#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
(QIconEngineFactoryInterface_iid, QLatin1String("/iconengines"), Qt::CaseInsensitive))
@ -537,8 +536,6 @@ QFactoryLoader *qt_iconEngineFactoryLoader()
{
return loader();
}
#endif
/*!
@ -1015,7 +1012,6 @@ void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State
return;
detach();
if (!d) {
#ifndef QT_NO_LIBRARY
QFileInfo info(fileName);
QString suffix = info.suffix();
if (!suffix.isEmpty()) {
@ -1030,7 +1026,6 @@ void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State
}
}
}
#endif
// ...then fall back to the default engine
if (!d) {
d = new QIconPrivate;
@ -1330,7 +1325,6 @@ QDataStream &operator>>(QDataStream &s, QIcon &icon)
QIconEngine *engine = new QIconLoaderEngine();
icon.d->engine = engine;
engine->read(s);
#ifndef QT_NO_LIBRARY
} else {
const int index = loader()->indexOf(key);
if (index != -1) {
@ -1342,7 +1336,6 @@ QDataStream &operator>>(QDataStream &s, QIcon &icon)
} // factory
} // instance
} // index
#endif
}
} else if (s.version() == QDataStream::Qt_4_2) {
icon = QIcon();

View File

@ -94,9 +94,7 @@ static inline QStringList systemIconSearchPaths()
return QStringList();
}
#ifndef QT_NO_LIBRARY
extern QFactoryLoader *qt_iconEngineFactoryLoader(); // qicon.cpp
#endif
void QIconLoader::ensureInitialized()
{
@ -109,10 +107,8 @@ void QIconLoader::ensureInitialized()
if (m_systemTheme.isEmpty())
m_systemTheme = fallbackTheme();
#ifndef QT_NO_LIBRARY
if (qt_iconEngineFactoryLoader()->keyMap().key(QLatin1String("svg"), -1) != -1)
m_supportsSvg = true;
#endif //QT_NO_LIBRARY
}
}

View File

@ -1414,7 +1414,6 @@ Q_GLOBAL_STATIC(QPHList, pictureHandlers)
void qt_init_picture_plugins()
{
#ifndef QT_NO_LIBRARY
typedef QMultiMap<int, QString> PluginKeyMap;
typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator;
@ -1429,7 +1428,6 @@ void qt_init_picture_plugins()
if (QPictureFormatPlugin *format = qobject_cast<QPictureFormatPlugin*>(loader.instance(it.key())))
format->installIOHandler(it.value());
}
#endif
}
static void cleanup()

View File

@ -38,7 +38,7 @@
****************************************************************************/
#include "qpictureformatplugin.h"
#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_PICTURE)
#if !defined(QT_NO_PICTURE)
#include "qpicture.h"
QT_BEGIN_NAMESPACE
@ -130,6 +130,6 @@ bool QPictureFormatPlugin::savePicture(const QString &format, const QString &fil
return false;
}
#endif // QT_NO_LIBRARY || QT_NO_PICTURE
#endif // QT_NO_PICTURE
QT_END_NAMESPACE

View File

@ -46,7 +46,7 @@
QT_BEGIN_NAMESPACE
#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_PICTURE)
#if !defined(QT_NO_PICTURE)
class QPicture;
class QImage;
@ -68,7 +68,7 @@ public:
};
#endif // QT_NO_LIBRARY || QT_NO_PICTURE
#endif // QT_NO_PICTURE
QT_END_NAMESPACE

View File

@ -46,16 +46,10 @@
QT_BEGIN_NAMESPACE
#if !defined(Q_OS_WIN32) || defined(QT_SHARED)
#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
(QGenericPluginFactoryInterface_iid,
QLatin1String("/generic"), Qt::CaseInsensitive))
#endif //QT_NO_LIBRARY
#endif //QT_SHARED
/*!
\class QGenericPluginFactory
\ingroup plugins
@ -75,15 +69,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
*/
QObject *QGenericPluginFactory::create(const QString& key, const QString &specification)
{
#if (!defined(Q_OS_WIN32) || defined(QT_SHARED)) && !defined(QT_NO_LIBRARY)
const QString driver = key.toLower();
if (QObject *object = qLoadPlugin<QObject, QGenericPlugin>(loader(), driver, specification))
return object;
#else // (!Q_OS_WIN32 || QT_SHARED) && !QT_NO_LIBRARY
Q_UNUSED(key)
Q_UNUSED(specification)
#endif
return 0;
return qLoadPlugin<QObject, QGenericPlugin>(loader(), key.toLower(), specification);
}
/*!
@ -95,8 +81,6 @@ QStringList QGenericPluginFactory::keys()
{
QStringList list;
#if !defined(Q_OS_WIN32) || defined(QT_SHARED)
#ifndef QT_NO_LIBRARY
typedef QMultiMap<int, QString> PluginKeyMap;
typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator;
@ -105,8 +89,6 @@ QStringList QGenericPluginFactory::keys()
for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend; ++it)
if (!list.contains(it.value()))
list += it.value();
#endif //QT_NO_LIBRARY
#endif
return list;
}

View File

@ -48,14 +48,14 @@
QT_BEGIN_NAMESPACE
#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
#ifndef QT_NO_SETTINGS
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
(QPlatformInputContextFactoryInterface_iid, QLatin1String("/platforminputcontexts"), Qt::CaseInsensitive))
#endif
QStringList QPlatformInputContextFactory::keys()
{
#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
#ifndef QT_NO_SETTINGS
return loader()->keyMap().values();
#else
return QStringList();
@ -70,7 +70,7 @@ QString QPlatformInputContextFactory::requested()
QPlatformInputContext *QPlatformInputContextFactory::create(const QString& key)
{
#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
#ifndef QT_NO_SETTINGS
if (!key.isEmpty()) {
QStringList paramList = key.split(QLatin1Char(':'));
const QString platform = paramList.takeFirst().toLower();

View File

@ -80,8 +80,8 @@ QPlatformIntegration *QPlatformIntegrationFactory::create(const QString &platfor
QStringList QPlatformIntegrationFactory::keys(const QString &platformPluginPath)
{
#ifndef QT_NO_LIBRARY
QStringList list;
#ifndef QT_NO_LIBRARY
if (!platformPluginPath.isEmpty()) {
QCoreApplication::addLibraryPath(platformPluginPath);
list = directLoader()->keyMap().values();
@ -94,12 +94,11 @@ QStringList QPlatformIntegrationFactory::keys(const QString &platformPluginPath)
(*it).append(postFix);
}
}
list.append(loader()->keyMap().values());
return list;
#else
Q_UNUSED(platformPluginPath);
return QStringList();
#endif
list.append(loader()->keyMap().values());
return list;
}
QT_END_NAMESPACE

View File

@ -48,31 +48,29 @@
QT_BEGIN_NAMESPACE
#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
(QPlatformThemeFactoryInterface_iid, QLatin1String("/platformthemes"), Qt::CaseInsensitive))
#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
(QPlatformThemeFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
#endif
QPlatformTheme *QPlatformThemeFactory::create(const QString& key, const QString &platformPluginPath)
{
#ifndef QT_NO_LIBRARY
QStringList paramList = key.split(QLatin1Char(':'));
const QString platform = paramList.takeFirst().toLower();
#ifndef QT_NO_LIBRARY
// Try loading the plugin from platformPluginPath first:
if (!platformPluginPath.isEmpty()) {
QCoreApplication::addLibraryPath(platformPluginPath);
if (QPlatformTheme *ret = qLoadPlugin<QPlatformTheme, QPlatformThemePlugin>(directLoader(), platform, paramList))
return ret;
}
return qLoadPlugin<QPlatformTheme, QPlatformThemePlugin>(loader(), platform, paramList);
#else
Q_UNUSED(key);
Q_UNUSED(platformPluginPath);
return 0;
#endif
return qLoadPlugin<QPlatformTheme, QPlatformThemePlugin>(loader(), platform, paramList);
}
/*!
@ -83,9 +81,9 @@ QPlatformTheme *QPlatformThemeFactory::create(const QString& key, const QString
*/
QStringList QPlatformThemeFactory::keys(const QString &platformPluginPath)
{
#ifndef QT_NO_LIBRARY
QStringList list;
#ifndef QT_NO_LIBRARY
if (!platformPluginPath.isEmpty()) {
QCoreApplication::addLibraryPath(platformPluginPath);
list += directLoader()->keyMap().values();
@ -98,12 +96,11 @@ QStringList QPlatformThemeFactory::keys(const QString &platformPluginPath)
(*it).append(postFix);
}
}
list += loader()->keyMap().values();
return list;
#else
Q_UNUSED(platformPluginPath);
return QStringList();
#endif
list += loader()->keyMap().values();
return list;
}
QT_END_NAMESPACE

View File

@ -367,10 +367,8 @@ void QNetworkConfigurationManagerPrivate::configurationChanged(QNetworkConfigura
void QNetworkConfigurationManagerPrivate::updateConfigurations()
{
#ifndef QT_NO_LIBRARY
typedef QMultiMap<int, QString> PluginKeyMap;
typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator;
#endif
QMutexLocker locker(&mutex);
if (firstUpdate) {
@ -379,7 +377,6 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
updating = false;
#ifndef QT_NO_LIBRARY
bool envOK = false;
const int skipGeneric = qEnvironmentVariableIntValue("QT_EXCLUDE_GENERIC_BEARER", &envOK);
QBearerEngine *generic = 0;
@ -421,7 +418,6 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
if (!envOK || skipGeneric <= 0)
sessionEngines.append(generic);
}
#endif // QT_NO_LIBRARY
}
QBearerEngine *engine = qobject_cast<QBearerEngine *>(sender());

View File

@ -63,20 +63,18 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(qLcEglDevDebug, "qt.qpa.egldeviceintegration")
#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
(QEGLDeviceIntegrationFactoryInterface_iid, QLatin1String("/egldeviceintegrations"), Qt::CaseInsensitive))
#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
(QEGLDeviceIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
#endif // QT_NO_LIBRARY
QStringList QEGLDeviceIntegrationFactory::keys(const QString &pluginPath)
{
#ifndef QT_NO_LIBRARY
QStringList list;
#ifndef QT_NO_LIBRARY
if (!pluginPath.isEmpty()) {
QCoreApplication::addLibraryPath(pluginPath);
list = directLoader()->keyMap().values();
@ -89,13 +87,12 @@ QStringList QEGLDeviceIntegrationFactory::keys(const QString &pluginPath)
(*it).append(postFix);
}
}
#else
Q_UNUSED(pluginPath);
#endif
list.append(loader()->keyMap().values());
qCDebug(qLcEglDevDebug) << "EGL device integration plugin keys:" << list;
return list;
#else
Q_UNUSED(pluginPath);
return QStringList();
#endif
}
QEGLDeviceIntegration *QEGLDeviceIntegrationFactory::create(const QString &key, const QString &pluginPath)
@ -106,16 +103,16 @@ QEGLDeviceIntegration *QEGLDeviceIntegrationFactory::create(const QString &key,
QCoreApplication::addLibraryPath(pluginPath);
integration = qLoadPlugin<QEGLDeviceIntegration, QEGLDeviceIntegrationPlugin>(directLoader(), key);
}
#else
Q_UNUSED(pluginPath);
#endif
if (!integration)
integration = qLoadPlugin<QEGLDeviceIntegration, QEGLDeviceIntegrationPlugin>(loader(), key);
if (integration)
qCDebug(qLcEglDevDebug) << "Using EGL device integration" << key;
else
qCWarning(qLcEglDevDebug) << "Failed to load EGL device integration" << key;
#else
Q_UNUSED(key);
Q_UNUSED(pluginPath);
#endif
return integration;
}

View File

@ -47,17 +47,18 @@
QT_BEGIN_NAMESPACE
#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
(QXcbGlIntegrationFactoryInterface_iid, QLatin1String("/xcbglintegrations"), Qt::CaseInsensitive))
#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
(QXcbGlIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
#endif // !QT_NO_LIBRARY
QStringList QXcbGlIntegrationFactory::keys(const QString &pluginPath)
{
#ifndef QT_NO_LIBRARY
QStringList list;
#ifndef QT_NO_LIBRARY
if (!pluginPath.isEmpty()) {
QCoreApplication::addLibraryPath(pluginPath);
list = directLoader()->keyMap().values();
@ -70,12 +71,11 @@ QStringList QXcbGlIntegrationFactory::keys(const QString &pluginPath)
(*it).append(postFix);
}
}
list.append(loader()->keyMap().values());
return list;
#else
Q_UNUSED(pluginPath);
return QStringList();
#endif
list.append(loader()->keyMap().values());
return list;
}
QXcbGlIntegration *QXcbGlIntegrationFactory::create(const QString &platform, const QString &pluginPath)
@ -87,13 +87,10 @@ QXcbGlIntegration *QXcbGlIntegrationFactory::create(const QString &platform, con
if (QXcbGlIntegration *ret = qLoadPlugin<QXcbGlIntegration, QXcbGlIntegrationPlugin>(directLoader(), platform))
return ret;
}
if (QXcbGlIntegration *ret = qLoadPlugin<QXcbGlIntegration, QXcbGlIntegrationPlugin>(loader(), platform))
return ret;
#else
Q_UNUSED(platform);
Q_UNUSED(pluginPath);
#endif
return Q_NULLPTR;
return qLoadPlugin<QXcbGlIntegration, QXcbGlIntegrationPlugin>(loader(), platform);
}
QT_END_NAMESPACE

View File

@ -45,10 +45,8 @@
QT_BEGIN_NAMESPACE
#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
(QPlatformPrinterSupportFactoryInterface_iid, QLatin1String("/printsupport"), Qt::CaseInsensitive))
#endif
QPlatformPrinterSupportPlugin::QPlatformPrinterSupportPlugin(QObject *parent)
: QObject(parent)
@ -61,15 +59,11 @@ QPlatformPrinterSupportPlugin::~QPlatformPrinterSupportPlugin()
static QPlatformPrinterSupport *printerSupport = 0;
#ifndef QT_NO_LIBRARY
static void cleanupPrinterSupport()
{
#ifndef QT_NO_PRINTER
delete printerSupport;
#endif
printerSupport = 0;
}
#endif // !QT_NO_LIBRARY
/*!
\internal
@ -81,7 +75,6 @@ static void cleanupPrinterSupport()
*/
QPlatformPrinterSupport *QPlatformPrinterSupportPlugin::get()
{
#ifndef QT_NO_LIBRARY
if (!printerSupport) {
const QMultiMap<int, QString> keyMap = loader()->keyMap();
if (!keyMap.isEmpty())
@ -89,7 +82,6 @@ QPlatformPrinterSupport *QPlatformPrinterSupportPlugin::get()
if (printerSupport)
qAddPostRoutine(cleanupPrinterSupport);
}
#endif // !QT_NO_LIBRARY
return printerSupport;
}

View File

@ -99,11 +99,9 @@
QT_BEGIN_NAMESPACE
#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
(QSqlDriverFactoryInterface_iid,
QLatin1String("/sqldrivers")))
#endif
#if !defined(Q_CC_MSVC) || _MSC_VER >= 1900
// ### Qt6: remove the #ifdef
@ -577,7 +575,6 @@ QStringList QSqlDatabase::drivers()
list << QLatin1String("QIBASE");
#endif
#ifndef QT_NO_LIBRARY
if (QFactoryLoader *fl = loader()) {
typedef QMultiMap<int, QString> PluginKeyMap;
typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator;
@ -588,7 +585,6 @@ QStringList QSqlDatabase::drivers()
if (!list.contains(it.value()))
list << it.value();
}
#endif
DriverDict dict = QSqlDatabasePrivate::driverDict();
for (DriverDict::const_iterator i = dict.constBegin(); i != dict.constEnd(); ++i) {
@ -778,10 +774,8 @@ void QSqlDatabasePrivate::init(const QString &type)
}
}
#ifndef QT_NO_LIBRARY
if (!driver && loader())
driver = qLoadPlugin<QSqlDriver, QSqlDriverPlugin>(loader(), type);
#endif // QT_NO_LIBRARY
if (!driver) {
qWarning("QSqlDatabase: %s driver not loaded", type.toLatin1().data());

View File

@ -69,10 +69,8 @@
QT_BEGIN_NAMESPACE
#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
(QStyleFactoryInterface_iid, QLatin1String("/styles"), Qt::CaseInsensitive))
#endif
/*!
\class QStyleFactory
@ -156,10 +154,8 @@ QStyle *QStyleFactory::create(const QString& key)
} else
#endif
{ } // Keep these here - they make the #ifdefery above work
#ifndef QT_NO_LIBRARY
if (!ret)
ret = qLoadPlugin<QStyle, QStylePlugin>(loader(), style);
#endif
if(ret)
ret->setObjectName(style);
return ret;
@ -174,14 +170,12 @@ QStyle *QStyleFactory::create(const QString& key)
QStringList QStyleFactory::keys()
{
QStringList list;
#ifndef QT_NO_LIBRARY
typedef QMultiMap<int, QString> PluginKeyMap;
const PluginKeyMap keyMap = loader()->keyMap();
const PluginKeyMap::const_iterator cend = keyMap.constEnd();
for (PluginKeyMap::const_iterator it = keyMap.constBegin(); it != cend; ++it)
list.append(it.value());
#endif
#ifndef QT_NO_STYLE_WINDOWS
if (!list.contains(QLatin1String("Windows")))
list << QLatin1String("Windows");