summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-10-01 03:02:06 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-10-01 03:02:06 +0200
commit486c51912393bf56cae0e45931fb135579a930d3 (patch)
tree9e4c32ef3c9b4d5f4a44504447e31f92f33f1252
parent03e160cfd286bb336e875a180efd83635be7a27f (diff)
parent1ed0782e93dafb0a3d5ef3a02c9c3999825817ee (diff)
Merge remote-tracking branch 'origin/5.13' into 5.14v5.14.0-beta1
-rw-r--r--src/client/qwaylandwindow.cpp6
-rw-r--r--tests/auto/client/client/tst_client.cpp11
2 files changed, 15 insertions, 2 deletions
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index ccf4f8dac..2704705e7 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -303,8 +303,10 @@ void QWaylandWindow::setWindowTitle(const QString &title)
const QString formatted = formatWindowTitle(title, separator);
const int libwaylandMaxBufferSize = 4096;
- // Some parts of the buffer is used for metadata, so subtract 100 to be on the safe side
- const int maxLength = libwaylandMaxBufferSize - 100;
+ // Some parts of the buffer is used for metadata, so subtract 100 to be on the safe side.
+ // Also, QString is in utf-16, which means that in the worst case each character will be
+ // three bytes when converted to utf-8 (which is what libwayland uses), so divide by three.
+ const int maxLength = libwaylandMaxBufferSize / 3 - 100;
auto truncated = QStringRef(&formatted).left(maxLength);
if (truncated.length() < formatted.length()) {
diff --git a/tests/auto/client/client/tst_client.cpp b/tests/auto/client/client/tst_client.cpp
index e9ae5e4b3..e19acff7c 100644
--- a/tests/auto/client/client/tst_client.cpp
+++ b/tests/auto/client/client/tst_client.cpp
@@ -184,6 +184,7 @@ private slots:
void glWindow();
#endif // QT_CONFIG(opengl)
void longWindowTitle();
+ void longWindowTitleWithUtf16Characters();
private:
MockCompositor *compositor = nullptr;
@@ -502,6 +503,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);