diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2018-05-31 11:20:28 +0200 |
---|---|---|
committer | Johan Helsing <johan.helsing@qt.io> | 2018-06-06 12:19:09 +0000 |
commit | 590d2e313c5a10dc9c7d61a654ada451e5df82aa (patch) | |
tree | 6d052c667e935baa75db777608281dd3f039e0e1 /src/client/qwaylandwindow.cpp | |
parent | 82e6b7953841015de040c892fcf53ca3c202d8b8 (diff) |
Don't ask libwayland to set absurdly long window titles
It will cause libwayland to terminate the application.
Task-number: QTBUG-68715
Change-Id: I1d1830453da224bec8bf4c5d6ab087c0e05328a8
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/client/qwaylandwindow.cpp')
-rw-r--r-- | src/client/qwaylandwindow.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index fdfd66688..5d658f675 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -287,7 +287,18 @@ void QWaylandWindow::setWindowTitle(const QString &title) { if (mShellSurface) { const QString separator = QString::fromUtf8(" \xe2\x80\x94 "); // unicode character U+2014, EM DASH - mShellSurface->setTitle(formatWindowTitle(title, separator)); + 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; + + auto truncated = QStringRef(&formatted).left(maxLength); + if (truncated.length() < formatted.length()) { + qCWarning(lcQpaWayland) << "Window titles longer than" << maxLength << "characters are not supported." + << "Truncating window title (from" << formatted.length() << "chars)"; + } + mShellSurface->setTitle(truncated.toString()); } if (mWindowDecoration && window()->isVisible()) |