Fix build with various features disabled

Change-Id: I95cb3cf3434306344af3f4c7556f45dbfa0b08d6
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
This commit is contained in:
Lars Knoll 2016-08-29 10:29:47 +02:00
parent 369857d294
commit 93b78e7c61
6 changed files with 25 additions and 3 deletions

View File

@ -45,15 +45,19 @@ QT_BEGIN_NAMESPACE
Q_GLOBAL_STATIC(QCoreGlobalData, globalInstance) Q_GLOBAL_STATIC(QCoreGlobalData, globalInstance)
QCoreGlobalData::QCoreGlobalData() QCoreGlobalData::QCoreGlobalData()
#if QT_CONFIG(textcodec)
: codecForLocale(0) : codecForLocale(0)
#endif
{ {
} }
QCoreGlobalData::~QCoreGlobalData() QCoreGlobalData::~QCoreGlobalData()
{ {
#if QT_CONFIG(textcodec)
codecForLocale = 0; codecForLocale = 0;
for (QList<QTextCodec *>::const_iterator it = allCodecs.constBegin(); it != allCodecs.constEnd(); ++it) for (QList<QTextCodec *>::const_iterator it = allCodecs.constBegin(); it != allCodecs.constEnd(); ++it)
delete *it; delete *it;
#endif
} }
QCoreGlobalData *QCoreGlobalData::instance() QCoreGlobalData *QCoreGlobalData::instance()

View File

@ -71,9 +71,11 @@ struct QCoreGlobalData {
QMap<QString, QStringList> dirSearchPaths; QMap<QString, QStringList> dirSearchPaths;
QReadWriteLock dirSearchPathsLock; QReadWriteLock dirSearchPathsLock;
#if QT_CONFIG(textcodec)
QList<QTextCodec*> allCodecs; QList<QTextCodec*> allCodecs;
QAtomicPointer<QTextCodec> codecForLocale; QAtomicPointer<QTextCodec> codecForLocale;
QTextCodecCache codecCache; QTextCodecCache codecCache;
#endif
static QCoreGlobalData *instance(); static QCoreGlobalData *instance();
}; };

View File

@ -238,6 +238,7 @@ static QList<QSize> availableXdgFileIconSizes()
return QIcon::fromTheme(QStringLiteral("inode-directory")).availableSizes(); return QIcon::fromTheme(QStringLiteral("inode-directory")).availableSizes();
} }
#if QT_CONFIG(mimetype)
static QIcon xdgFileIcon(const QFileInfo &fileInfo) static QIcon xdgFileIcon(const QFileInfo &fileInfo)
{ {
QMimeDatabase mimeDatabase; QMimeDatabase mimeDatabase;
@ -253,6 +254,7 @@ static QIcon xdgFileIcon(const QFileInfo &fileInfo)
const QString &genericIconName = mimeType.genericIconName(); const QString &genericIconName = mimeType.genericIconName();
return genericIconName.isEmpty() ? QIcon() : QIcon::fromTheme(genericIconName); return genericIconName.isEmpty() ? QIcon() : QIcon::fromTheme(genericIconName);
} }
#endif
#ifndef QT_NO_SETTINGS #ifndef QT_NO_SETTINGS
class QKdeThemePrivate : public QPlatformThemePrivate class QKdeThemePrivate : public QPlatformThemePrivate
@ -547,7 +549,11 @@ QVariant QKdeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
QIcon QKdeTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions) const QIcon QKdeTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions) const
{ {
#if QT_CONFIG(mimetype)
return xdgFileIcon(fileInfo); return xdgFileIcon(fileInfo);
#else
return QIcon();
#endif
} }
const QPalette *QKdeTheme::palette(Palette type) const const QPalette *QKdeTheme::palette(Palette type) const
@ -708,7 +714,11 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
QIcon QGnomeTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions) const QIcon QGnomeTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions) const
{ {
#if QT_CONFIG(mimetype)
return xdgFileIcon(fileInfo); return xdgFileIcon(fileInfo);
#else
return QIcon();
#endif
} }
const QFont *QGnomeTheme::font(Font type) const const QFont *QGnomeTheme::font(Font type) const

View File

@ -258,7 +258,7 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s)
free_prop = true; free_prop = true;
} }
#ifndef QT_NO_TEXTCODEC #if QT_CONFIG(textcodec)
static const QTextCodec* mapper = QTextCodec::codecForLocale(); static const QTextCodec* mapper = QTextCodec::codecForLocale();
int errCode = 0; int errCode = 0;
if (mapper) { if (mapper) {
@ -274,6 +274,7 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s)
mapper = QTextCodec::codecForName("latin1"); mapper = QTextCodec::codecForName("latin1");
if (!mapper || !mapper->canEncode(s)) if (!mapper || !mapper->canEncode(s))
return Q_NULLPTR; return Q_NULLPTR;
#endif
static QByteArray qcs; static QByteArray qcs;
qcs = s.toLatin1(); qcs = s.toLatin1();
tp.value = (uchar*)qcs.data(); tp.value = (uchar*)qcs.data();
@ -281,6 +282,7 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s)
tp.format = 8; tp.format = 8;
tp.nitems = qcs.length(); tp.nitems = qcs.length();
free_prop = false; free_prop = false;
#if QT_CONFIG(textcodec)
} }
#endif #endif
return &tp; return &tp;

View File

@ -59,7 +59,7 @@ QPlatformPrintDevice::QPlatformPrintDevice()
m_haveOutputBins(false), m_haveOutputBins(false),
m_haveDuplexModes(false), m_haveDuplexModes(false),
m_haveColorModes(false) m_haveColorModes(false)
#ifndef QT_NO_MIMETYPES #ifndef QT_NO_MIMETYPE
, m_haveMimeTypes(false) , m_haveMimeTypes(false)
#endif #endif
{ {
@ -77,7 +77,7 @@ QPlatformPrintDevice::QPlatformPrintDevice(const QString &id)
m_haveOutputBins(false), m_haveOutputBins(false),
m_haveDuplexModes(false), m_haveDuplexModes(false),
m_haveColorModes(false) m_haveColorModes(false)
#ifndef QT_NO_MIMETYPES #ifndef QT_NO_MIMETYPE
, m_haveMimeTypes(false) , m_haveMimeTypes(false)
#endif #endif
{ {

View File

@ -187,7 +187,9 @@ void QPixmapStyle::polish(QWidget *widget)
view->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); view->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
} }
#if QT_CONFIG(gestures)
QScroller::grabGesture(scrollArea->viewport(), QScroller::LeftMouseButtonGesture); QScroller::grabGesture(scrollArea->viewport(), QScroller::LeftMouseButtonGesture);
#endif
} }
if (qobject_cast<QScrollBar*>(widget)) if (qobject_cast<QScrollBar*>(widget))
@ -217,8 +219,10 @@ void QPixmapStyle::unpolish(QWidget *widget)
if (qstrcmp(widget->metaObject()->className(),"QComboBoxPrivateContainer") == 0) if (qstrcmp(widget->metaObject()->className(),"QComboBoxPrivateContainer") == 0)
widget->removeEventFilter(this); widget->removeEventFilter(this);
#if QT_CONFIG(gestures)
if (QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(widget)) if (QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(widget))
QScroller::ungrabGesture(scrollArea->viewport()); QScroller::ungrabGesture(scrollArea->viewport());
#endif
QCommonStyle::unpolish(widget); QCommonStyle::unpolish(widget);
} }