Skip to content

Commit 73907e3

Browse files
paulobertdewey-rpi
authored andcommitted
fix(NativeFileDialog/MacOS): Fix dialog window binding
Signed-off-by: paul.oberosler <[email protected]>
1 parent 4aaea62 commit 73907e3

File tree

1 file changed

+10
-26
lines changed

1 file changed

+10
-26
lines changed

src/mac/nativefiledialog_macos.mm

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,12 @@ QString convertQtFilterToMacOS(const QString &qtFilter)
6262
// Process events once to allow QML cleanup, then show dialog with minimal delay
6363
QCoreApplication::processEvents();
6464

65-
// Get the native NSWindow if parentWindow is provided
66-
NSWindow *nsParentWindow = nil;
67-
if (parentWindow) {
68-
QWindow *window = static_cast<QWindow*>(parentWindow);
69-
NSView *view = reinterpret_cast<NSView*>(window->winId());
70-
if (view) {
71-
nsParentWindow = [view window];
72-
}
73-
}
65+
// Parent window parameter is unused on macOS
66+
// Native panels always run as application-modal dialogs
67+
Q_UNUSED(parentWindow);
7468

7569
// Use a very short timer to minimize delay while still avoiding Qt conflicts
76-
QTimer::singleShot(1, [&, nsParentWindow]() {
70+
QTimer::singleShot(1, [&]() {
7771
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
7872

7973
NSString *nsTitle = title.isEmpty() ? nil : title.toNSString();
@@ -108,14 +102,9 @@ QString convertQtFilterToMacOS(const QString &qtFilter)
108102
}
109103
}
110104

111-
NSInteger buttonPressed;
112-
if (nsParentWindow) {
113-
// Run as sheet modal to parent window
114-
buttonPressed = [panel runModalForWindow:nsParentWindow];
115-
} else {
116-
// Run as application modal dialog
117-
buttonPressed = [panel runModal];
118-
}
105+
// Simply run as application modal dialog
106+
// Sheet modals require async handling which complicates Qt integration
107+
NSInteger buttonPressed = [panel runModal];
119108

120109
if (buttonPressed == NSModalResponseOK) {
121110
NSURL *url = [panel URL];
@@ -143,14 +132,9 @@ QString convertQtFilterToMacOS(const QString &qtFilter)
143132
}
144133
}
145134

146-
NSInteger buttonPressed;
147-
if (nsParentWindow) {
148-
// Run as sheet modal to parent window
149-
buttonPressed = [panel runModalForWindow:nsParentWindow];
150-
} else {
151-
// Run as application modal dialog
152-
buttonPressed = [panel runModal];
153-
}
135+
// Simply run as application modal dialog
136+
// Sheet modals require async handling which complicates Qt integration
137+
NSInteger buttonPressed = [panel runModal];
154138

155139
if (buttonPressed == NSModalResponseOK) {
156140
NSArray *urls = [panel URLs];

0 commit comments

Comments
 (0)