aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/textadept.c
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+667e-11@users.noreply.github.com>2018-01-31 17:46:51 -0500
committerGravatar mitchell <70453897+667e-11@users.noreply.github.com>2018-01-31 17:46:51 -0500
commit0648cd2795c1427603e642c2057cf3ffea9acf60 (patch)
tree4c05b2cde8530374c59ad41573744a080d9b55a3 /src/textadept.c
parentc5a0b961f5f955b5c7924fbbb8c453edd6ecd699 (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.c14
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