Fix: Ensure MFC and Web remote desktop sessions are fully independent

This commit is contained in:
yuanyuanxiang
2026-05-02 13:56:08 +02:00
parent 171fa750e5
commit 9ae5529458
8 changed files with 163 additions and 45 deletions

View File

@@ -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);
}