From 4d489ce721ff8a037d20b6aa8d2cafad0cb2f6d7 Mon Sep 17 00:00:00 2001 From: Ingo Richter Date: Fri, 30 May 2014 14:55:22 -0700 Subject: [PATCH 1/3] - this is a fix for https://github.com/adobe/brackets/issues/7752 --- appshell/client_handler.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/appshell/client_handler.cpp b/appshell/client_handler.cpp index 625a70e3f..b97a8309a 100644 --- a/appshell/client_handler.cpp +++ b/appshell/client_handler.cpp @@ -353,8 +353,13 @@ void ClientHandler::SendOpenFileCommand(CefRefPtr browser, const Cef std::string fileArrayStr(fileArray); // FIXME: Use SendJSCommand once it supports parameters std::string cmd = "require('command/CommandManager').execute('file.openDroppedFiles'," + fileArrayStr + ")"; - browser->GetMainFrame()->ExecuteJavaScript(CefString(cmd.c_str()), + + // if files are droppend and the Open Dialog is visible, then browser is NULL + // This fixes https://github.com/adobe/brackets/issues/7752 + if (browser) { + browser->GetMainFrame()->ExecuteJavaScript(CefString(cmd.c_str()), browser->GetMainFrame()->GetURL(), 0); + } } void ClientHandler::DispatchCloseToNextBrowser() From 65526e000494a08d8a7709a867e7fcbb7a01762f Mon Sep 17 00:00:00 2001 From: Ingo Richter Date: Fri, 15 Aug 2014 17:00:14 -0700 Subject: [PATCH 2/3] - remove the NULL check and determine the main windows if a modal dialog is opened and derive the CefBrowser instance from that window --- appshell/cefclient_mac.mm | 11 +++++++++++ appshell/client_handler.cpp | 6 +----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/appshell/cefclient_mac.mm b/appshell/cefclient_mac.mm index 16b3e072e..4b7bb6d20 100644 --- a/appshell/cefclient_mac.mm +++ b/appshell/cefclient_mac.mm @@ -691,6 +691,17 @@ - (BOOL)application:(NSApplication *)theApplication openFiles:(NSArray *)filenam ClientApplication * clientApp = (ClientApplication *)theApplication; NSWindow* targetWindow = [clientApp findTargetWindow]; if (targetWindow) { + // if files are droppend and the Open/Save Dialog is visible, then browser is NULL + // find the main window. If this is not the main window, then it's a modal dialog like open or save. The main + // window has a reference to the CerBrowser instance + // This fixes https://github.com/adobe/brackets/issues/7752 + if (![targetWindow isMainWindow]) { + targetWindow = [targetWindow parentWindow]; + } + + // move App window to front + [targetWindow orderFront: self]; + CefRefPtr browser = ClientHandler::GetBrowserForNativeWindow(targetWindow); NSUInteger count = [filenames count]; if (count) { diff --git a/appshell/client_handler.cpp b/appshell/client_handler.cpp index b97a8309a..94a5244e7 100644 --- a/appshell/client_handler.cpp +++ b/appshell/client_handler.cpp @@ -354,12 +354,8 @@ void ClientHandler::SendOpenFileCommand(CefRefPtr browser, const Cef // FIXME: Use SendJSCommand once it supports parameters std::string cmd = "require('command/CommandManager').execute('file.openDroppedFiles'," + fileArrayStr + ")"; - // if files are droppend and the Open Dialog is visible, then browser is NULL - // This fixes https://github.com/adobe/brackets/issues/7752 - if (browser) { - browser->GetMainFrame()->ExecuteJavaScript(CefString(cmd.c_str()), + browser->GetMainFrame()->ExecuteJavaScript(CefString(cmd.c_str()), browser->GetMainFrame()->GetURL(), 0); - } } void ClientHandler::DispatchCloseToNextBrowser() From 26795a1da28831c53840353421de993e1807481d Mon Sep 17 00:00:00 2001 From: Ingo Richter Date: Tue, 19 Aug 2014 17:14:43 -0700 Subject: [PATCH 3/3] - revert to previous fix, since this one seems not to work properly on OSX 10.8.x --- appshell/cefclient_mac.mm | 11 ----------- appshell/client_handler.cpp | 6 +++++- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/appshell/cefclient_mac.mm b/appshell/cefclient_mac.mm index 4b7bb6d20..16b3e072e 100644 --- a/appshell/cefclient_mac.mm +++ b/appshell/cefclient_mac.mm @@ -691,17 +691,6 @@ - (BOOL)application:(NSApplication *)theApplication openFiles:(NSArray *)filenam ClientApplication * clientApp = (ClientApplication *)theApplication; NSWindow* targetWindow = [clientApp findTargetWindow]; if (targetWindow) { - // if files are droppend and the Open/Save Dialog is visible, then browser is NULL - // find the main window. If this is not the main window, then it's a modal dialog like open or save. The main - // window has a reference to the CerBrowser instance - // This fixes https://github.com/adobe/brackets/issues/7752 - if (![targetWindow isMainWindow]) { - targetWindow = [targetWindow parentWindow]; - } - - // move App window to front - [targetWindow orderFront: self]; - CefRefPtr browser = ClientHandler::GetBrowserForNativeWindow(targetWindow); NSUInteger count = [filenames count]; if (count) { diff --git a/appshell/client_handler.cpp b/appshell/client_handler.cpp index 94a5244e7..b97a8309a 100644 --- a/appshell/client_handler.cpp +++ b/appshell/client_handler.cpp @@ -354,8 +354,12 @@ void ClientHandler::SendOpenFileCommand(CefRefPtr browser, const Cef // FIXME: Use SendJSCommand once it supports parameters std::string cmd = "require('command/CommandManager').execute('file.openDroppedFiles'," + fileArrayStr + ")"; - browser->GetMainFrame()->ExecuteJavaScript(CefString(cmd.c_str()), + // if files are droppend and the Open Dialog is visible, then browser is NULL + // This fixes https://github.com/adobe/brackets/issues/7752 + if (browser) { + browser->GetMainFrame()->ExecuteJavaScript(CefString(cmd.c_str()), browser->GetMainFrame()->GetURL(), 0); + } } void ClientHandler::DispatchCloseToNextBrowser()