summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2019-09-18 08:56:57 +0200
committerJohan Helsing <johan.helsing@qt.io>2019-09-25 13:52:27 +0000
commit45859d7521074a4921b8459eb0a6e2cc71b9dd5a (patch)
treeafd555c4235f85b1db8fde0b2c365b15606f4bb0 /tests
parent90f9c3c6fdb323a7fd509cb7fc018472cc5d1c13 (diff)
Client: Don't crash with long window titles using UTF-16 characters
Previously, we set the max length in QString character length, which means UTF-16 characters (of potentially three bytes) counts as one character. The max limit of libwayland, however, is in bytes (and the string itself is converted to UTF-8). Fix it by dividing the character limit by three because in the worst case each UTF-16 character will use three bytes when UTF-8 encoded. Fixes: QTBUG-78478 Change-Id: Idf4721894e0fe6f3cd92bdc6ada7b0ea4199ea63 (cherry picked from commit 1ed0782e93dafb0a3d5ef3a02c9c3999825817ee) Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/client/client/tst_client.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/auto/client/client/tst_client.cpp b/tests/auto/client/client/tst_client.cpp
index 470db25a4..82ec30510 100644
--- a/tests/auto/client/client/tst_client.cpp
+++ b/tests/auto/client/client/tst_client.cpp
@@ -183,6 +183,7 @@ private slots:
void hiddenPopupParent();
void glWindow();
void longWindowTitle();
+ void longWindowTitleWithUtf16Characters();
private:
MockCompositor *compositor = nullptr;
@@ -610,6 +611,16 @@ void tst_WaylandClient::longWindowTitle()
QTRY_VERIFY(compositor->surface());
}
+void tst_WaylandClient::longWindowTitleWithUtf16Characters()
+{
+ QWindow window;
+ QString absurdlyLongTitle = QString("δΈ‰").repeated(10000);
+ Q_ASSERT(absurdlyLongTitle.length() == 10000); // just making sure the test isn't broken
+ window.setTitle(absurdlyLongTitle);
+ window.show();
+ QTRY_VERIFY(compositor->surface());
+}
+
int main(int argc, char **argv)
{
setenv("XDG_RUNTIME_DIR", ".", 1);