mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-03-28 20:45:32 +08:00
[fix] fix raw pointer issues when closing connections
This commit is contained in:
@@ -893,7 +893,7 @@ void Render::UpdateInteractions() {
|
|||||||
mouse_controller_is_started_ = false;
|
mouse_controller_is_started_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start_keyboard_capturer_ && foucs_on_stream_window_) {
|
if (start_keyboard_capturer_ && focus_on_stream_window_) {
|
||||||
if (!keyboard_capturer_is_started_) {
|
if (!keyboard_capturer_is_started_) {
|
||||||
StartKeyboardCapturer();
|
StartKeyboardCapturer();
|
||||||
keyboard_capturer_is_started_ = true;
|
keyboard_capturer_is_started_ = true;
|
||||||
@@ -2176,7 +2176,7 @@ void Render::ProcessSdlEvent(const SDL_Event& event) {
|
|||||||
case SDL_EVENT_WINDOW_FOCUS_GAINED:
|
case SDL_EVENT_WINDOW_FOCUS_GAINED:
|
||||||
if (stream_window_ &&
|
if (stream_window_ &&
|
||||||
SDL_GetWindowID(stream_window_) == event.window.windowID) {
|
SDL_GetWindowID(stream_window_) == event.window.windowID) {
|
||||||
foucs_on_stream_window_ = true;
|
focus_on_stream_window_ = true;
|
||||||
} else if (main_window_ &&
|
} else if (main_window_ &&
|
||||||
SDL_GetWindowID(main_window_) == event.window.windowID) {
|
SDL_GetWindowID(main_window_) == event.window.windowID) {
|
||||||
foucs_on_main_window_ = true;
|
foucs_on_main_window_ = true;
|
||||||
@@ -2186,7 +2186,7 @@ void Render::ProcessSdlEvent(const SDL_Event& event) {
|
|||||||
case SDL_EVENT_WINDOW_FOCUS_LOST:
|
case SDL_EVENT_WINDOW_FOCUS_LOST:
|
||||||
if (stream_window_ &&
|
if (stream_window_ &&
|
||||||
SDL_GetWindowID(stream_window_) == event.window.windowID) {
|
SDL_GetWindowID(stream_window_) == event.window.windowID) {
|
||||||
foucs_on_stream_window_ = false;
|
focus_on_stream_window_ = false;
|
||||||
} else if (main_window_ &&
|
} else if (main_window_ &&
|
||||||
SDL_GetWindowID(main_window_) == event.window.windowID) {
|
SDL_GetWindowID(main_window_) == event.window.windowID) {
|
||||||
foucs_on_main_window_ = false;
|
foucs_on_main_window_ = false;
|
||||||
@@ -2200,7 +2200,7 @@ void Render::ProcessSdlEvent(const SDL_Event& event) {
|
|||||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||||
case SDL_EVENT_MOUSE_BUTTON_UP:
|
case SDL_EVENT_MOUSE_BUTTON_UP:
|
||||||
case SDL_EVENT_MOUSE_WHEEL:
|
case SDL_EVENT_MOUSE_WHEEL:
|
||||||
if (foucs_on_stream_window_) {
|
if (focus_on_stream_window_) {
|
||||||
ProcessMouseEvent(event);
|
ProcessMouseEvent(event);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -434,7 +434,7 @@ class Render {
|
|||||||
bool show_cursor_ = false;
|
bool show_cursor_ = false;
|
||||||
bool keyboard_capturer_is_started_ = false;
|
bool keyboard_capturer_is_started_ = false;
|
||||||
bool foucs_on_main_window_ = false;
|
bool foucs_on_main_window_ = false;
|
||||||
bool foucs_on_stream_window_ = false;
|
bool focus_on_stream_window_ = false;
|
||||||
bool main_window_minimized_ = false;
|
bool main_window_minimized_ = false;
|
||||||
uint32_t last_main_minimize_request_tick_ = 0;
|
uint32_t last_main_minimize_request_tick_ = 0;
|
||||||
uint32_t last_stream_minimize_request_tick_ = 0;
|
uint32_t last_stream_minimize_request_tick_ = 0;
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ int Render::StreamWindow() {
|
|||||||
UpdateRenderRect();
|
UpdateRenderRect();
|
||||||
|
|
||||||
ControlWindow(props);
|
ControlWindow(props);
|
||||||
|
|
||||||
// Show file transfer window if needed
|
// Show file transfer window if needed
|
||||||
FileTransferWindow(props);
|
FileTransferWindow(props);
|
||||||
|
|
||||||
@@ -151,12 +151,12 @@ int Render::StreamWindow() {
|
|||||||
// std::unique_lock unique_lock(client_properties_mutex_);
|
// std::unique_lock unique_lock(client_properties_mutex_);
|
||||||
auto erase_it = client_properties_.find(remote_id_to_erase);
|
auto erase_it = client_properties_.find(remote_id_to_erase);
|
||||||
if (erase_it != client_properties_.end()) {
|
if (erase_it != client_properties_.end()) {
|
||||||
erase_it = client_properties_.erase(erase_it);
|
// Ensure we flush pending STREAM_REFRESH_EVENT events and
|
||||||
if (client_properties_.empty()) {
|
// clean up peer resources before erasing the entry, otherwise
|
||||||
SDL_Event event;
|
// SDL events may still hold raw pointers to freed
|
||||||
event.type = SDL_EVENT_QUIT;
|
// SubStreamWindowProperties (including video_frame_mutex_),
|
||||||
SDL_PushEvent(&event);
|
// leading to std::system_error when locking.
|
||||||
}
|
CloseTab(erase_it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// lock.lock();
|
// lock.lock();
|
||||||
@@ -236,10 +236,10 @@ int Render::StreamWindow() {
|
|||||||
UpdateRenderRect();
|
UpdateRenderRect();
|
||||||
|
|
||||||
ControlWindow(props);
|
ControlWindow(props);
|
||||||
|
|
||||||
// Show file transfer window if needed
|
// Show file transfer window if needed
|
||||||
FileTransferWindow(props);
|
FileTransferWindow(props);
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
|
||||||
if (!props->peer_) {
|
if (!props->peer_) {
|
||||||
@@ -251,12 +251,7 @@ int Render::StreamWindow() {
|
|||||||
// std::unique_lock unique_lock(client_properties_mutex_);
|
// std::unique_lock unique_lock(client_properties_mutex_);
|
||||||
auto erase_it = client_properties_.find(remote_id_to_erase);
|
auto erase_it = client_properties_.find(remote_id_to_erase);
|
||||||
if (erase_it != client_properties_.end()) {
|
if (erase_it != client_properties_.end()) {
|
||||||
client_properties_.erase(erase_it);
|
CloseTab(erase_it);
|
||||||
if (client_properties_.empty()) {
|
|
||||||
SDL_Event event;
|
|
||||||
event.type = SDL_EVENT_QUIT;
|
|
||||||
SDL_PushEvent(&event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// lock.lock();
|
// lock.lock();
|
||||||
|
|||||||
Reference in New Issue
Block a user