From 1d80626400f6b86ccb13f09f4c5f5be198571694 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 6 Sep 2023 14:30:24 +0200 Subject: [PATCH] macOS: Use non-native fallback for message boxes with rich text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The NSAlert messageText and informativeText properties only allow plain NSString, so we need to opt out of the native dialog if the user has requested rich text for any of these properties. Fixes: QTBUG-116757 Pick-to: 6.5 Change-Id: I3fd44ec94adad1dda1ed4dede46450a8a525d35f Reviewed-by: Tor Arne Vestbø (cherry picked from commit 28ab45182a3fea76193146083838cca4212395d2) Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoamessagedialog.mm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoamessagedialog.mm b/src/plugins/platforms/cocoa/qcocoamessagedialog.mm index 43d767d32b7..b09f6bf54e6 100644 --- a/src/plugins/platforms/cocoa/qcocoamessagedialog.mm +++ b/src/plugins/platforms/cocoa/qcocoamessagedialog.mm @@ -91,6 +91,13 @@ bool QCocoaMessageDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality w if (!options()) return false; + if (Qt::mightBeRichText(options()->text()) || + Qt::mightBeRichText(options()->informativeText())) { + // Let's fallback to non-native message box, + // we only have plain NSString/text in NSAlert. + qCDebug(lcQpaDialogs, "Message box contains text in rich text format"); + return false; + } Q_ASSERT(!m_alert); m_alert = [NSAlert new];