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:
Lars Knoll 2020-04-28 20:56:17 +02:00
parent 4db2f067f1
commit 5e5085c3bb
2 changed files with 9 additions and 22 deletions

View File

@ -39,7 +39,6 @@
#include "qxcbmime.h"
#include <QtCore/QTextCodec>
#include <QtGui/QImageWriter>
#include <QtCore/QBuffer>
#include <qdebug.h>

View File

@ -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)