From 2561c7cd657d6bf4c5487ed22048892fd8cdc001 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 3 Jan 2024 15:32:50 +0100 Subject: [PATCH] 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. Change-Id: If706b8faa7027ca284ec8398f5c6e2a110e01f91 Reviewed-by: Timur Pocheptsov (cherry picked from commit 942f5b23c2a279499e1e59ab283f5bafc54659e0) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index cd92c59a5eb..15ec46a453c 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -368,6 +368,14 @@ typedef QSharedPointer 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) {