diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-10-19 03:02:22 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-10-19 03:02:23 +0200 |
commit | d418818bfcb64289c02dcb8a7abffc8ac2568fae (patch) | |
tree | f06634b34d811de9337392f7e2ebf1582b905e2b | |
parent | 4ece435e82964833dc35c143cddc08bc84b0e1fb (diff) | |
parent | 1df9e1896b3760b72e518f473a97050e8cf229b0 (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: Ie9d7d49216b7d03f83306cf06f6439080f3457a3
-rw-r--r-- | src/client/qwaylandwindow.cpp | 6 | ||||
-rw-r--r-- | src/compositor/compositor_api/qwaylandcompositor.cpp | 4 | ||||
-rw-r--r-- | tests/auto/client/client/tst_client.cpp | 11 |
3 files changed, 17 insertions, 4 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/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp index e2d617c37..ee55aa4b0 100644 --- a/src/compositor/compositor_api/qwaylandcompositor.cpp +++ b/src/compositor/compositor_api/qwaylandcompositor.cpp @@ -206,11 +206,11 @@ void QWaylandCompositorPrivate::init() if (!socket_name.isEmpty()) { if (wl_display_add_socket(display, socket_name.constData())) - qFatal("Fatal: Failed to open server socket\n"); + qFatal("Fatal: Failed to open server socket: \"%s\". XDG_RUNTIME_DIR is: \"%s\"\n", socket_name.constData(), getenv("XDG_RUNTIME_DIR")); } else { const char *autoSocketName = wl_display_add_socket_auto(display); if (!autoSocketName) - qFatal("Fatal: Failed to open server socket\n"); + qFatal("Fatal: Failed to open default server socket. XDG_RUNTIME_DIR is: \"%s\"\n", getenv("XDG_RUNTIME_DIR")); socket_name = autoSocketName; emit q->socketNameChanged(socket_name); } 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); |