[fix] resolve issue where configuration settings were not saved

This commit is contained in:
dijunkun
2025-11-03 10:55:19 +08:00
parent 43db021326
commit b3132db785
4 changed files with 17 additions and 6 deletions

View File

@@ -181,8 +181,9 @@ int ConfigCenter::SetServerPort(int signal_server_port) {
int ConfigCenter::SetCoturnServerPort(int coturn_server_port) {
coturn_server_port_ = coturn_server_port;
SI_Error rc = ini_.SetLongValue(section_, "coturn_server_port",
static_cast<long>(coturn_server_port_));
ini_.SetLongValue(section_, "coturn_server_port",
static_cast<long>(coturn_server_port_));
SI_Error rc = ini_.SaveFile(config_path_.c_str());
if (rc < 0) {
return -1;
}
@@ -201,6 +202,7 @@ int ConfigCenter::SetCertFilePath(const std::string& cert_file_path) {
int ConfigCenter::SetSelfHosted(bool enable_self_hosted) {
enable_self_hosted_ = enable_self_hosted;
ini_.SetBoolValue(section_, "enable_self_hosted", enable_self_hosted_);
SI_Error rc = ini_.SaveFile(config_path_.c_str());
if (rc < 0) {
return -1;
@@ -210,6 +212,12 @@ int ConfigCenter::SetSelfHosted(bool enable_self_hosted) {
int ConfigCenter::SetMinimizeToTray(bool enable_minimize_to_tray) {
enable_minimize_to_tray_ = enable_minimize_to_tray;
ini_.SetBoolValue(section_, "enable_minimize_to_tray",
enable_minimize_to_tray_);
SI_Error rc = ini_.SaveFile(config_path_.c_str());
if (rc < 0) {
return -1;
}
return 0;
}

View File

@@ -258,6 +258,7 @@ int Render::LoadSettingsFromCacheFile() {
enable_hardware_video_codec_ = config_center_->IsHardwareVideoCodec();
enable_turn_ = config_center_->IsEnableTurn();
enable_srtp_ = config_center_->IsEnableSrtp();
enable_self_hosted_ = config_center_->IsSelfHosted();
language_button_value_last_ = language_button_value_;
video_quality_button_value_last_ = video_quality_button_value_;
@@ -265,6 +266,7 @@ int Render::LoadSettingsFromCacheFile() {
enable_hardware_video_codec_last_ = enable_hardware_video_codec_;
enable_turn_last_ = enable_turn_;
enable_srtp_last_ = enable_srtp_;
enable_self_hosted_last_ = enable_self_hosted_;
LOG_INFO("Load settings from cache file");

View File

@@ -445,13 +445,14 @@ class Render {
char signal_server_port_[6] = "9099";
char coturn_server_port_[6] = "3478";
char cert_file_path_[256] = "";
bool enable_self_hosted_server_ = false;
bool enable_self_hosted_ = false;
int language_button_value_last_ = 0;
int video_quality_button_value_last_ = 0;
int video_encode_format_button_value_last_ = 0;
bool enable_hardware_video_codec_last_ = false;
bool enable_turn_last_ = false;
bool enable_srtp_last_ = false;
bool enable_self_hosted_last_ = false;
bool enable_minimize_to_tray_ = false;
bool enable_minimize_to_tray_last_ = false;
char signal_server_ip_self_[256] = "";

View File

@@ -231,8 +231,7 @@ int Render::SettingWindow() {
ImGui::SetCursorPosX(ENABLE_SELF_HOSTED_SERVER_CHECKBOX_PADDING_EN);
}
ImGui::SetCursorPosY(settings_items_offset);
ImGui::Checkbox("##enable_self_hosted_server",
&enable_self_hosted_server_);
ImGui::Checkbox("##enable_self_hosted", &enable_self_hosted_);
}
#if _WIN32
ImGui::Separator();
@@ -332,11 +331,12 @@ int Render::SettingWindow() {
}
enable_srtp_last_ = enable_srtp_;
if (enable_self_hosted_server_) {
if (enable_self_hosted_) {
config_center_->SetSelfHosted(true);
} else {
config_center_->SetSelfHosted(false);
}
enable_self_hosted_last_ = enable_self_hosted_;
settings_window_pos_reset_ = true;