From 0648cd2795c1427603e642c2057cf3ffea9acf60 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Wed, 31 Jan 2018 17:46:51 -0500 Subject: 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. --- src/textadept.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') 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 -- cgit v1.2.3