mirror of https://github.com/qt/qtgamepad.git
Fix build with -no-feature-library
The previous code produced warnings about unused parameters. We can actually load (static) plugins without QLibrary. Try to do so and warn if we are trying to load from a specific location. Change-Id: Icd396f1e4bb2d5200b1693d2230d87b502aa275b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
parent
72be0422f9
commit
752d431966
|
|
@ -38,22 +38,23 @@
|
||||||
#include "qgamepadbackendplugin_p.h"
|
#include "qgamepadbackendplugin_p.h"
|
||||||
#include "qgamepadbackend_p.h"
|
#include "qgamepadbackend_p.h"
|
||||||
|
|
||||||
|
#include <QtCore/qdebug.h>
|
||||||
#include <QtCore/private/qfactoryloader_p.h>
|
#include <QtCore/private/qfactoryloader_p.h>
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
#ifndef QT_NO_LIBRARY
|
|
||||||
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QtGamepadBackendFactoryInterface_iid, QLatin1String("/gamepads"), Qt::CaseInsensitive))
|
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QtGamepadBackendFactoryInterface_iid, QLatin1String("/gamepads"), Qt::CaseInsensitive))
|
||||||
|
#if QT_CONFIG(library)
|
||||||
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader, (QtGamepadBackendFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
|
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader, (QtGamepadBackendFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QStringList QGamepadBackendFactory::keys(const QString &pluginPath)
|
QStringList QGamepadBackendFactory::keys(const QString &pluginPath)
|
||||||
{
|
{
|
||||||
#ifndef QT_NO_LIBRARY
|
|
||||||
QStringList list;
|
QStringList list;
|
||||||
if (!pluginPath.isEmpty()) {
|
if (!pluginPath.isEmpty()) {
|
||||||
|
#if QT_CONFIG(library)
|
||||||
QCoreApplication::addLibraryPath(pluginPath);
|
QCoreApplication::addLibraryPath(pluginPath);
|
||||||
list = directLoader()->keyMap().values();
|
list = directLoader()->keyMap().values();
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
|
|
@ -64,25 +65,29 @@ QStringList QGamepadBackendFactory::keys(const QString &pluginPath)
|
||||||
for (QStringList::iterator it = list.begin(); it != end; ++it)
|
for (QStringList::iterator it = list.begin(); it != end; ++it)
|
||||||
(*it).append(postFix);
|
(*it).append(postFix);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
qWarning("Cannot query QGamepadBackend plugins at %s: Library loading is disabled.",
|
||||||
|
pluginPath.toLocal8Bit().constData());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
list.append(loader()->keyMap().values());
|
list.append(loader()->keyMap().values());
|
||||||
return list;
|
return list;
|
||||||
#else
|
|
||||||
return QStringList();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QGamepadBackend *QGamepadBackendFactory::create(const QString &name, const QStringList &args, const QString &pluginPath)
|
QGamepadBackend *QGamepadBackendFactory::create(const QString &name, const QStringList &args, const QString &pluginPath)
|
||||||
{
|
{
|
||||||
#ifndef QT_NO_LIBRARY
|
|
||||||
if (!pluginPath.isEmpty()) {
|
if (!pluginPath.isEmpty()) {
|
||||||
|
#if QT_CONFIG(library)
|
||||||
QCoreApplication::addLibraryPath(pluginPath);
|
QCoreApplication::addLibraryPath(pluginPath);
|
||||||
if (QGamepadBackend *ret = qLoadPlugin<QGamepadBackend, QGamepadBackendPlugin>(directLoader(), name, args))
|
if (QGamepadBackend *ret = qLoadPlugin<QGamepadBackend, QGamepadBackendPlugin>(directLoader(), name, args))
|
||||||
return ret;
|
return ret;
|
||||||
|
#else
|
||||||
|
qWarning("Cannot load QGamepadBackend plugin from %s. Library loading is disabled.",
|
||||||
|
pluginPath.toLocal8Bit().constData());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (QGamepadBackend *ret = qLoadPlugin<QGamepadBackend, QGamepadBackendPlugin>(loader(), name, args))
|
if (QGamepadBackend *ret = qLoadPlugin<QGamepadBackend, QGamepadBackendPlugin>(loader(), name, args))
|
||||||
return ret;
|
return ret;
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue