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

Commit 74861bd

Browse files
committed
Merge pull request #534 from adobe/revert-524-fix-11112
Revert "Fix for #11112: Command line: "brackets" without arguments al…
2 parents b11da5f + a5e64c5 commit 74861bd

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

appshell/cefclient_win.cpp

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -193,35 +193,33 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
193193

194194
// Determine if we should use an already running instance of Brackets.
195195
HANDLE hMutex = ::OpenMutex(MUTEX_ALL_ACCESS, FALSE, FIRST_INSTANCE_MUTEX_NAME);
196-
if (hMutex != NULL) {
197-
// for subsequent instances, re-use an already running instance if we're being called to
198-
// open an existing file on the command-line (eg. Open With.. from Windows Explorer)
199-
HWND hFirstInstanceWnd = cef_main_window::FindFirstTopLevelInstance();
200-
if (hFirstInstanceWnd != NULL) {
201-
::SetForegroundWindow(hFirstInstanceWnd);
202-
if (::IsIconic(hFirstInstanceWnd))
203-
::ShowWindow(hFirstInstanceWnd, SW_RESTORE);
204-
// Check for arguments. If any pass it to the existing running instance.
205-
if( AppGetCommandLine()->HasArguments() && (lpCmdLine != NULL) ){
206-
// message the other Brackets instance to actually open the given filename
207-
std::wstring filename = lpCmdLine;
208-
std::wstring wstrFilename;
209-
// We check if this is a valid file path. If not just ignore this parameter.
210-
if (GetFullPath(filename, wstrFilename)) {
211-
ConvertToUnixPath(wstrFilename);
212-
// note: WM_COPYDATA will manage passing the string across process space
213-
COPYDATASTRUCT data;
214-
data.dwData = ID_WM_COPYDATA_SENDOPENFILECOMMAND;
215-
data.cbData = (wstrFilename.length() + 1) * sizeof(WCHAR);
216-
data.lpData = (LPVOID)wstrFilename.c_str();
217-
::SendMessage(hFirstInstanceWnd, WM_COPYDATA, (WPARAM)(HWND)hFirstInstanceWnd, (LPARAM)(LPVOID)&data);
218-
}
196+
if ((hMutex != NULL) && AppGetCommandLine()->HasArguments() && (lpCmdLine != NULL)) {
197+
// for subsequent instances, re-use an already running instance if we're being called to
198+
// open an existing file on the command-line (eg. Open With.. from Windows Explorer)
199+
HWND hFirstInstanceWnd = cef_main_window::FindFirstTopLevelInstance();
200+
if (hFirstInstanceWnd != NULL) {
201+
::SetForegroundWindow(hFirstInstanceWnd);
202+
if (::IsIconic(hFirstInstanceWnd))
203+
::ShowWindow(hFirstInstanceWnd, SW_RESTORE);
204+
205+
// message the other Brackets instance to actually open the given filename
206+
std::wstring filename = lpCmdLine;
207+
std::wstring wstrFilename;
208+
// We check if this is a valid file path. If not just ignore this parameter.
209+
if (GetFullPath(filename, wstrFilename)) {
210+
ConvertToUnixPath(wstrFilename);
211+
// note: WM_COPYDATA will manage passing the string across process space
212+
COPYDATASTRUCT data;
213+
data.dwData = ID_WM_COPYDATA_SENDOPENFILECOMMAND;
214+
data.cbData = (wstrFilename.length() + 1) * sizeof(WCHAR);
215+
data.lpData = (LPVOID)wstrFilename.c_str();
216+
::SendMessage(hFirstInstanceWnd, WM_COPYDATA, (WPARAM)(HWND)hFirstInstanceWnd, (LPARAM)(LPVOID)&data);
217+
// exit this instance
218+
return 0;
219219
}
220-
// exit this instance
221-
return 0;
222220
}
223221
// otherwise, fall thru and launch a new instance
224-
}
222+
}
225223

226224
if (hMutex == NULL) {
227225
// first instance of this app, so create the mutex and continue execution of this instance.

0 commit comments

Comments
 (0)