diff --git a/src/plugins/platforms/wayland/qwaylanddataoffer.cpp b/src/plugins/platforms/wayland/qwaylanddataoffer.cpp index 35085a7f0d5..0c732c02078 100644 --- a/src/plugins/platforms/wayland/qwaylanddataoffer.cpp +++ b/src/plugins/platforms/wayland/qwaylanddataoffer.cpp @@ -135,7 +135,7 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T } int pipefd[2]; - if (::pipe2(pipefd, O_CLOEXEC|O_NONBLOCK) == -1) { + if (qt_safe_pipe(pipefd, O_NONBLOCK) == -1) { qWarning("QWaylandMimeData: pipe2() failed"); return QVariant(); } diff --git a/src/plugins/platforms/wayland/qwaylanddataoffer_p.h b/src/plugins/platforms/wayland/qwaylanddataoffer_p.h index 3e88b8f4ba2..5412400a59e 100644 --- a/src/plugins/platforms/wayland/qwaylanddataoffer_p.h +++ b/src/plugins/platforms/wayland/qwaylanddataoffer_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include +#include #include #include diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index a3ae802ffae..e935ef31f5f 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -52,7 +52,12 @@ #include "qwaylandwindowmanagerintegration_p.h" #include "qwaylandscreen_p.h" -#include +#if defined(Q_OS_MACOS) +# include +# include +#else +# include +#endif #include #include @@ -118,7 +123,11 @@ public: }; QWaylandIntegration::QWaylandIntegration() +#if defined(Q_OS_MACOS) + : mFontDb(new QCoreTextFontDatabaseEngineFactory) +#else : mFontDb(new QGenericUnixFontDatabase()) +#endif , mNativeInterface(new QWaylandNativeInterface(this)) #if QT_CONFIG(accessibility) , mAccessibility(new QPlatformAccessibility()) diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index ef49e8ea8c8..e071330634f 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -282,7 +282,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()) diff --git a/tests/auto/wayland/client/tst_client.cpp b/tests/auto/wayland/client/tst_client.cpp index 21f748ecd4f..6b7daecd5f1 100644 --- a/tests/auto/wayland/client/tst_client.cpp +++ b/tests/auto/wayland/client/tst_client.cpp @@ -162,6 +162,7 @@ public slots: // make sure the surfaces from the last test are properly cleaned up // and don't show up as false positives in the next test QTRY_VERIFY(!compositor->surface()); + QTRY_VERIFY(!compositor->iviSurface()); QTRY_VERIFY(!compositor->xdgToplevelV6()); } @@ -181,6 +182,7 @@ private slots: void hiddenTransientParent(); void hiddenPopupParent(); void glWindow(); + void longWindowTitle(); private: MockCompositor *compositor = nullptr; @@ -597,6 +599,16 @@ void tst_WaylandClient::glWindow() QTRY_VERIFY(!compositor->surface()); } +void tst_WaylandClient::longWindowTitle() +{ + // See QTBUG-68715 + QWindow window; + QString absurdlyLongTitle(10000, QLatin1Char('z')); + window.setTitle(absurdlyLongTitle); + window.show(); + QTRY_VERIFY(compositor->surface()); +} + int main(int argc, char **argv) { setenv("XDG_RUNTIME_DIR", ".", 1);