[Spice-devel] [PATCH 4/5] Pass class pointer using thread parameter

Frediano Ziglio fziglio at redhat.com
Fri Aug 12 11:02:08 UTC 2016


Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 vdagent/vdagent.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index bbf0989..9d0b5bd 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -246,16 +246,17 @@ VDAgent::~VDAgent()
 
 DWORD WINAPI VDAgent::event_thread_proc(LPVOID param)
 {
+    VDAgent *agent = static_cast<VDAgent *>(param);
     HANDLE desktop_event = OpenEvent(SYNCHRONIZE, FALSE, L"WinSta0_DesktopSwitch");
     if (!desktop_event) {
         vd_printf("OpenEvent() failed: %lu", GetLastError());
         return 1;
     }
-    while (_singleton->_running) {
+    while (agent->_running) {
         DWORD wait_ret = WaitForSingleObject(desktop_event, INFINITE);
         switch (wait_ret) {
         case WAIT_OBJECT_0:
-            _singleton->set_control_event(CONTROL_DESKTOP_SWITCH);
+            agent->set_control_event(CONTROL_DESKTOP_SWITCH);
             break;
         case WAIT_TIMEOUT:
         default:
@@ -331,7 +332,7 @@ bool VDAgent::run()
         return false;
     }
     _running = true;
-    event_thread = CreateThread(NULL, 0, event_thread_proc, NULL, 0, &event_thread_id);
+    event_thread = CreateThread(NULL, 0, event_thread_proc, this, 0, &event_thread_id);
     if (!event_thread) {
         vd_printf("CreateThread() failed: %lu", GetLastError());
         cleanup();
-- 
2.7.4



More information about the Spice-devel mailing list