From 80c8bb28b6feb12cbbc2cbb895cb7dc6e8a520fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sat, 9 Dec 2023 19:02:09 +0100 Subject: [PATCH] macOS: Handle NSNull when file dialog directories change For some directories, such as the 'Recents' entry in the native file dialog, the panel:directoryDidChange: callback will report a NSNull for the NSString path, which results in an exception when trying to compute the length of this null entry. Pick-to: 6.5 6.2 Change-Id: Ic9cddb54ea713b8fbdcaf0f4fb506ac96e90c9fe Reviewed-by: Volker Hilsheimer (cherry picked from commit 3bf7e0693ec1df01d2d27e28ab38f553beaa9c82) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit c8d2158bd243e236102c7b4e4fa4cf2433bd5931) --- src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index 4ddc8b9a237..f2161fd9a7d 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -379,7 +379,10 @@ typedef QSharedPointer SharedPointerFileDialogOptions; if (!m_helper) return; - if (!(path && path.length) || [path isEqualToString:m_currentDirectory]) + if (!path || [path isEqual:NSNull.null] || !path.length) + return; + + if ([path isEqualToString:m_currentDirectory]) return; [m_currentDirectory release];