From 87725ee75981ec9ab25456c41acc74681c85ae2e Mon Sep 17 00:00:00 2001 From: William Jones Date: Tue, 15 Feb 2022 18:26:21 -0500 Subject: [PATCH] QCocoaFileDialogHelper: Always enable symlinks and aliases to directories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We always enable directories, so that the user can navigate into them, so we should do the same for symlinks and aliases to directories. This is the same behavior the native dialog has when not implementing shouldEnableURL and relying purely on allowedFileTypes. Fixes: QTBUG-28379 Pick-to: 5.15 6.2 6.3 Change-Id: I7ae4eb8120aa87cb685f3561d5e1c7257b0c9349 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index 8bd649e4610..51925feb5b3 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -259,7 +259,12 @@ typedef QSharedPointer SharedPointerFileDialogOptions; } } - QString qtFileName = QFileInfo(QString::fromNSString(filename)).fileName(); + // Treat symbolic links and aliases to directories like directories + QFileInfo fileInfo(QString::fromNSString(filename)); + if (fileInfo.isSymLink() && QFileInfo(fileInfo.symLinkTarget()).isDir()) + return YES; + + QString qtFileName = fileInfo.fileName(); // No filter means accept everything bool nameMatches = m_selectedNameFilter->isEmpty(); // Check if the current file name filter accepts the file: