Fix: Ensure MFC and Web remote desktop sessions are fully independent
This commit is contained in:
@@ -651,11 +651,21 @@ public:
|
||||
// Double-check after acquiring lock
|
||||
if (m_destroyed) return;
|
||||
|
||||
// Prevent starting if thread is already running or joinable
|
||||
if (m_captureThread.joinable()) return;
|
||||
// If already running, just send TOKEN_BITMAPINFO again
|
||||
// This allows server to create additional dialogs (MFC can open while Web is active)
|
||||
if (m_captureThread.joinable() || m_running.load()) {
|
||||
Mprintf(">>> ScreenHandler already running, sending TOKEN_BITMAPINFO for new dialog\n");
|
||||
SendBitmapInfo();
|
||||
return;
|
||||
}
|
||||
|
||||
bool expected = false;
|
||||
if (!m_running.compare_exchange_strong(expected, true)) return;
|
||||
if (!m_running.compare_exchange_strong(expected, true)) {
|
||||
// Race condition: another thread started first, send bitmap info
|
||||
Mprintf(">>> ScreenHandler race, sending TOKEN_BITMAPINFO for new dialog\n");
|
||||
SendBitmapInfo();
|
||||
return;
|
||||
}
|
||||
|
||||
m_captureThread = std::thread(&ScreenHandler::CaptureLoop, this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user