summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2024-01-03 15:32:50 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2024-01-17 14:23:09 +0100
commit942f5b23c2a279499e1e59ab283f5bafc54659e0 (patch)
tree9bc1985fa5379a293e6078da40c94bcbcf2ab3e5 /src/plugins/platforms/cocoa
parent4ec386eeeadfd9b6cd9e64d5907c3c20493a0b68 (diff)
macOS: Disable currentChanged signal for NSSavePanels
The panelSelectionDidChange callback is only called when the user selects a directory in the save panel, as all other files are not selectable. And when that happens, the reported selection is not the directory, but the current file name (which may be based on clicking an exsiting file, but that doesn't cause selection changes). To avoid this confusing and inconsistent behavior we disable the signal entirely when showing an NSSavePanel. Pick-to: 6.7 Change-Id: If706b8faa7027ca284ec8398f5c6e2a110e01f91 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r--src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
index 96bf46f45a..677a339a4a 100644
--- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
@@ -376,6 +376,14 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
if (!m_helper)
return;
+ // Save panels only allow you to select directories, which
+ // means currentChanged will only be emitted when selecting
+ // a directory, and if so, with the latest chosen file name,
+ // which is confusing and inconsistent. We choose to bail
+ // out entirely for save panels, to give consistent behavior.
+ if (!openpanel_cast(m_panel))
+ return;
+
if (m_panel.visible) {
const QString selection = QString::fromNSString(m_panel.URL.path);
if (selection != m_currentSelection) {