Skip to content
This repository was archived by the owner on Sep 2, 2021. It is now read-only.

Commit 65526e0

Browse files
committed
- remove the NULL check and determine the main windows if a modal dialog is opened and derive the CefBrowser instance from that window
1 parent 9c7eb85 commit 65526e0

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

appshell/cefclient_mac.mm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,17 @@ - (BOOL)application:(NSApplication *)theApplication openFiles:(NSArray *)filenam
691691
ClientApplication * clientApp = (ClientApplication *)theApplication;
692692
NSWindow* targetWindow = [clientApp findTargetWindow];
693693
if (targetWindow) {
694+
// if files are droppend and the Open/Save Dialog is visible, then browser is NULL
695+
// find the main window. If this is not the main window, then it's a modal dialog like open or save. The main
696+
// window has a reference to the CerBrowser instance
697+
// This fixes https://github.com/adobe/brackets/issues/7752
698+
if (![targetWindow isMainWindow]) {
699+
targetWindow = [targetWindow parentWindow];
700+
}
701+
702+
// move App window to front
703+
[targetWindow orderFront: self];
704+
694705
CefRefPtr<CefBrowser> browser = ClientHandler::GetBrowserForNativeWindow(targetWindow);
695706
NSUInteger count = [filenames count];
696707
if (count) {

appshell/client_handler.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,8 @@ void ClientHandler::SendOpenFileCommand(CefRefPtr<CefBrowser> browser, const Cef
354354
// FIXME: Use SendJSCommand once it supports parameters
355355
std::string cmd = "require('command/CommandManager').execute('file.openDroppedFiles'," + fileArrayStr + ")";
356356

357-
// if files are droppend and the Open Dialog is visible, then browser is NULL
358-
// This fixes https://github.com/adobe/brackets/issues/7752
359-
if (browser) {
360-
browser->GetMainFrame()->ExecuteJavaScript(CefString(cmd.c_str()),
357+
browser->GetMainFrame()->ExecuteJavaScript(CefString(cmd.c_str()),
361358
browser->GetMainFrame()->GetURL(), 0);
362-
}
363359
}
364360

365361
void ClientHandler::DispatchCloseToNextBrowser()

0 commit comments

Comments
 (0)