Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: Ie9d7d49216b7d03f83306cf06f6439080f3457a3
This commit is contained in:
commit
d91b1b2796
@ -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()) {
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user