diff options
author | mitchell <70453897+667e-11@users.noreply.github.com> | 2018-01-31 17:46:51 -0500 |
---|---|---|
committer | mitchell <70453897+667e-11@users.noreply.github.com> | 2018-01-31 17:46:51 -0500 |
commit | 0648cd2795c1427603e642c2057cf3ffea9acf60 (patch) | |
tree | 4c05b2cde8530374c59ad41573744a080d9b55a3 /src/textadept.c | |
parent | c5a0b961f5f955b5c7924fbbb8c453edd6ecd699 (diff) |
Fixed busy wait in second instance of Textadept on Windows.
Other instances should not attempt to become the single instance by waiting on
a named pipe to be created, as it already exists.
Diffstat (limited to 'src/textadept.c')
-rw-r--r-- | src/textadept.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/textadept.c b/src/textadept.c index eaa94413..27df7144 100644 --- a/src/textadept.c +++ b/src/textadept.c @@ -83,12 +83,16 @@ typedef GtkWidget Scintilla; (WaitNamedPipe("\\\\.\\pipe\\textadept.editor", NMPWAIT_WAIT_FOREVER) != 0) #define g_application_run(_,__,___) win32_application_run() #define gtk_main() \ - HANDLE pipe = CreateNamedPipe("\\\\.\\pipe\\textadept.editor", \ - PIPE_ACCESS_INBOUND, PIPE_WAIT, 1, 0, 0, \ - INFINITE, NULL); \ - HANDLE thread = CreateThread(NULL, 0, &pipe_listener, pipe, 0, NULL); \ + HANDLE pipe = NULL, thread = NULL; \ + if (!g_application_get_is_remote(app)) { \ + pipe = CreateNamedPipe("\\\\.\\pipe\\textadept.editor", \ + PIPE_ACCESS_INBOUND, PIPE_WAIT, 1, 0, 0, INFINITE, \ + NULL); \ + thread = CreateThread(NULL, 0, &pipe_listener, pipe, 0, NULL); \ + } \ gtk_main(); \ - TerminateThread(thread, 0), CloseHandle(thread), CloseHandle(pipe); + if (pipe && thread) \ + TerminateThread(thread, 0), CloseHandle(thread), CloseHandle(pipe); #endif #endif |