From ea8e8fe3ed5cea6f937961c66b63983ed3e92a9d Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Tue, 18 Jun 2019 20:18:42 -0400 Subject: [PATCH] play nice with other (legacy) clipboard monitors --- GUI/host/host.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/GUI/host/host.cpp b/GUI/host/host.cpp index eff9c52..d297845 100644 --- a/GUI/host/host.cpp +++ b/GUI/host/host.cpp @@ -174,7 +174,13 @@ namespace Host std::thread([] { while (WaitForSingleObject(clipboardUpdate, INFINITE) == WAIT_OBJECT_0) - if (auto text = Util::GetClipboardText()) GetThread(clipboard).AddSentence(std::move(text.value())); + { + for (int retry = 0; retry < 3; ++retry) // retry loop in case something else is using the clipboard + { + Sleep(10); + if (auto text = Util::GetClipboardText()) GetThread(clipboard).AddSentence(std::move(text.value())); + } + } throw; }).detach(); }