Remove QTextCodec dependency from the xcb plugin
Change-Id: I4b6a7352ff86b40ac5c6b118f29f630a7f9e3a7e Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
4db2f067f1
commit
5e5085c3bb
@ -39,7 +39,6 @@
|
||||
|
||||
#include "qxcbmime.h"
|
||||
|
||||
#include <QtCore/QTextCodec>
|
||||
#include <QtGui/QImageWriter>
|
||||
#include <QtCore/QBuffer>
|
||||
#include <qdebug.h>
|
||||
|
@ -75,7 +75,6 @@
|
||||
#include <qpa/qplatformbackingstore.h>
|
||||
#include <qpa/qwindowsysteminterface.h>
|
||||
|
||||
#include <QTextCodec>
|
||||
#include <stdio.h>
|
||||
|
||||
#if QT_CONFIG(xcb_xlib)
|
||||
@ -184,23 +183,16 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s)
|
||||
free_prop = true;
|
||||
}
|
||||
|
||||
#if QT_CONFIG(textcodec)
|
||||
static const QTextCodec* mapper = QTextCodec::codecForLocale();
|
||||
int errCode = 0;
|
||||
if (mapper) {
|
||||
QByteArray mapped = mapper->fromUnicode(s);
|
||||
char* tl[2];
|
||||
tl[0] = mapped.data();
|
||||
tl[1] = nullptr;
|
||||
errCode = XmbTextListToTextProperty(dpy, tl, 1, XStdICCTextStyle, &tp);
|
||||
if (errCode < 0)
|
||||
qCDebug(lcQpaXcb, "XmbTextListToTextProperty result code %d", errCode);
|
||||
}
|
||||
if (!mapper || errCode < 0) {
|
||||
mapper = QTextCodec::codecForName("latin1");
|
||||
if (!mapper || !mapper->canEncode(s))
|
||||
return nullptr;
|
||||
#endif
|
||||
QByteArray mapped = s.toLocal8Bit(); // should always be utf-8
|
||||
char* tl[2];
|
||||
tl[0] = mapped.data();
|
||||
tl[1] = nullptr;
|
||||
errCode = XmbTextListToTextProperty(dpy, tl, 1, XStdICCTextStyle, &tp);
|
||||
if (errCode < 0)
|
||||
qCDebug(lcQpaXcb, "XmbTextListToTextProperty result code %d", errCode);
|
||||
|
||||
if (errCode < 0) {
|
||||
static QByteArray qcs;
|
||||
qcs = s.toLatin1();
|
||||
tp.value = (uchar*)qcs.data();
|
||||
@ -208,11 +200,7 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s)
|
||||
tp.format = 8;
|
||||
tp.nitems = qcs.length();
|
||||
free_prop = false;
|
||||
#if QT_CONFIG(textcodec)
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(dpy);
|
||||
#endif
|
||||
return &tp;
|
||||
}
|
||||
#endif // QT_CONFIG(xcb_xlib)
|
||||
|
Loading…
x
Reference in New Issue
Block a user