From f48085c69ad498907993d2c60e929afcea046d61 Mon Sep 17 00:00:00 2001 From: dijunkun Date: Wed, 9 Apr 2025 17:17:30 +0800 Subject: [PATCH] [fix] fix connection error when reinput password --- .../connection_status_window.cpp | 21 +++++++++---------- src/single_window/render_callback_func.cpp | 1 + 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/single_window/connection_status_window.cpp b/src/single_window/connection_status_window.cpp index 5cf9587..87f4983 100644 --- a/src/single_window/connection_status_window.cpp +++ b/src/single_window/connection_status_window.cpp @@ -4,7 +4,7 @@ #include "render.h" int Render::ConnectionStatusWindow( - std::shared_ptr &properties) { + std::shared_ptr &props) { if (show_connection_status_window_) { const ImGuiViewport *viewport = ImGui::GetMainViewport(); @@ -34,11 +34,11 @@ int Render::ConnectionStatusWindow( ImGui::SetWindowFontScale(0.5f); std::string text; - if (ConnectionStatus::Connecting == properties->connection_status_) { + if (ConnectionStatus::Connecting == props->connection_status_) { text = localization::p2p_connecting[localization_language_index_]; ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7); ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3); - } else if (ConnectionStatus::Connected == properties->connection_status_) { + } else if (ConnectionStatus::Connected == props->connection_status_) { text = localization::p2p_connected[localization_language_index_]; ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7); ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3); @@ -49,8 +49,7 @@ int Render::ConnectionStatusWindow( ImGui::IsKeyPressed(ImGuiKey_Escape)) { show_connection_status_window_ = false; } - } else if (ConnectionStatus::Disconnected == - properties->connection_status_) { + } else if (ConnectionStatus::Disconnected == props->connection_status_) { text = localization::p2p_disconnected[localization_language_index_]; ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7); ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3); @@ -61,7 +60,7 @@ int Render::ConnectionStatusWindow( ImGui::IsKeyPressed(ImGuiKey_Escape)) { show_connection_status_window_ = false; } - } else if (ConnectionStatus::Failed == properties->connection_status_) { + } else if (ConnectionStatus::Failed == props->connection_status_) { text = localization::p2p_failed[localization_language_index_]; ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7); ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3); @@ -72,7 +71,7 @@ int Render::ConnectionStatusWindow( ImGui::IsKeyPressed(ImGuiKey_Escape)) { show_connection_status_window_ = false; } - } else if (ConnectionStatus::Closed == properties->connection_status_) { + } else if (ConnectionStatus::Closed == props->connection_status_) { text = localization::p2p_closed[localization_language_index_]; ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7); ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3); @@ -84,7 +83,7 @@ int Render::ConnectionStatusWindow( show_connection_status_window_ = false; } } else if (ConnectionStatus::IncorrectPassword == - properties->connection_status_) { + props->connection_status_) { if (!password_validating_) { if (password_validating_time_ == 1) { text = localization::input_password[localization_language_index_]; @@ -118,7 +117,7 @@ int Render::ConnectionStatusWindow( ImGui::Checkbox( localization::remember_password[localization_language_index_] .c_str(), - &(properties->remember_password_)); + &(props->remember_password_)); ImGui::SetWindowFontScale(0.5f); ImGui::PopStyleVar(); @@ -130,7 +129,7 @@ int Render::ConnectionStatusWindow( ImGui::IsKeyPressed(ImGuiKey_Enter)) { show_connection_status_window_ = true; password_validating_ = true; - rejoin_ = true; + props->rejoin_ = true; focus_on_input_widget_ = true; } @@ -149,7 +148,7 @@ int Render::ConnectionStatusWindow( ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3); } } else if (ConnectionStatus::NoSuchTransmissionId == - properties->connection_status_) { + props->connection_status_) { text = localization::no_such_id[localization_language_index_]; ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7); ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3); diff --git a/src/single_window/render_callback_func.cpp b/src/single_window/render_callback_func.cpp index 9848bc7..8397c85 100644 --- a/src/single_window/render_callback_func.cpp +++ b/src/single_window/render_callback_func.cpp @@ -371,6 +371,7 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, const char *user_id, render->password_validating_ = false; render->password_validating_time_++; if (render->connect_button_pressed_) { + render->connect_button_pressed_ = false; props->connection_established_ = false; render->connect_button_label_ = render->connect_button_pressed_