[fix] fix crash when transmission id does not exist

This commit is contained in:
dijunkun
2025-08-19 16:33:29 +08:00
parent c7166975b3
commit 6f8fd6a030
5 changed files with 13 additions and 46 deletions

View File

@@ -3,7 +3,7 @@
#include "rd_log.h"
#include "render.h"
int Render::ConnectionStatusWindow(
bool Render::ConnectionStatusWindow(
std::shared_ptr<SubStreamWindowProperties> &props) {
if (show_connection_status_window_) {
const ImGuiViewport *viewport = ImGui::GetMainViewport();
@@ -160,7 +160,7 @@ int Render::ConnectionStatusWindow(
show_connection_status_window_ = false;
re_enter_remote_id_ = true;
DestroyPeer(&props->peer_);
client_properties_.erase(props->remote_id_);
return true;
}
}
@@ -175,5 +175,5 @@ int Render::ConnectionStatusWindow(
ImGui::End();
ImGui::PopStyleVar();
}
return 0;
return false;
}

View File

@@ -29,8 +29,13 @@ int Render::MainWindow() {
RecentConnectionsWindow();
StatusBar();
for (auto& it : client_properties_) {
ConnectionStatusWindow(it.second);
for (auto it = client_properties_.begin(); it != client_properties_.end();) {
auto& props = it->second;
if (ConnectionStatusWindow(props)) {
it = client_properties_.erase(it);
} else {
++it;
}
}
return 0;

View File

@@ -151,7 +151,8 @@ class Render {
int ControlBar(std::shared_ptr<SubStreamWindowProperties> &props);
int AboutWindow();
int StatusBar();
int ConnectionStatusWindow(std::shared_ptr<SubStreamWindowProperties> &props);
bool ConnectionStatusWindow(
std::shared_ptr<SubStreamWindowProperties> &props);
int ShowRecentConnections();
private: