From 5e5085c3bba07f093facbf5d48532cf77139751f Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 28 Apr 2020 20:56:17 +0200 Subject: [PATCH] Remove QTextCodec dependency from the xcb plugin Change-Id: I4b6a7352ff86b40ac5c6b118f29f630a7f9e3a7e Reviewed-by: Alex Blasche Reviewed-by: Shawn Rutledge Reviewed-by: Thiago Macieira --- src/plugins/platforms/xcb/qxcbmime.cpp | 1 - src/plugins/platforms/xcb/qxcbwindow.cpp | 30 +++++++----------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbmime.cpp b/src/plugins/platforms/xcb/qxcbmime.cpp index 0c07d847c2..6c5679135d 100644 --- a/src/plugins/platforms/xcb/qxcbmime.cpp +++ b/src/plugins/platforms/xcb/qxcbmime.cpp @@ -39,7 +39,6 @@ #include "qxcbmime.h" -#include #include #include #include diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 40106bbeaf..162554cf3d 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -75,7 +75,6 @@ #include #include -#include #include #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)