aboutsummaryrefslogtreecommitdiffstats
path: root/win/winvnc/STrayIcon.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'win/winvnc/STrayIcon.cxx')
-rw-r--r--win/winvnc/STrayIcon.cxx13
1 files changed, 5 insertions, 8 deletions
diff --git a/win/winvnc/STrayIcon.cxx b/win/winvnc/STrayIcon.cxx
index b8a57330..fc079e76 100644
--- a/win/winvnc/STrayIcon.cxx
+++ b/win/winvnc/STrayIcon.cxx
@@ -28,8 +28,6 @@
#include <core/Configuration.h>
#include <core/LogWriter.h>
-#include <core/Mutex.h>
-#include <core/Thread.h>
#include <rfb_win32/LaunchProcess.h>
#include <rfb_win32/TrayIcon.h>
@@ -217,7 +215,7 @@ public:
case WM_SET_TOOLTIP:
{
- AutoMutex a(thread.lock);
+ const std::lock_guard<std::mutex> a(thread.lock);
if (!thread.toolTip.empty())
setToolTip(thread.toolTip.c_str());
}
@@ -239,12 +237,11 @@ protected:
STrayIconThread::STrayIconThread(VNCServerWin32& sm, UINT inactiveIcon_, UINT activeIcon_,
UINT dis_inactiveIcon_, UINT dis_activeIcon_, UINT menu_)
-: thread_id(-1), windowHandle(nullptr), server(sm),
+: thread(&STrayIconThread::worker, this), thread_id(-1),
+ windowHandle(nullptr), server(sm),
inactiveIcon(inactiveIcon_), activeIcon(activeIcon_),
dis_inactiveIcon(dis_inactiveIcon_), dis_activeIcon(dis_activeIcon_),
menu(menu_), runTrayIcon(true) {
- lock = new Mutex;
- start();
while (thread_id == (DWORD)-1)
Sleep(0);
}
@@ -252,7 +249,7 @@ STrayIconThread::STrayIconThread(VNCServerWin32& sm, UINT inactiveIcon_, UINT ac
STrayIconThread::~STrayIconThread() {
runTrayIcon = false;
PostThreadMessage(thread_id, WM_QUIT, 0, 0);
- delete lock;
+ thread.join();
}
void STrayIconThread::worker() {
@@ -277,7 +274,7 @@ void STrayIconThread::worker() {
void STrayIconThread::setToolTip(const char* text) {
if (!windowHandle) return;
- AutoMutex a(lock);
+ const std::lock_guard<std::mutex> a(lock);
toolTip = text;
PostMessage(windowHandle, WM_SET_TOOLTIP, 0, 0);
}