From 9b100aa19ed935f15cd3e14d7c4105b15447d412 Mon Sep 17 00:00:00 2001 From: taynpg Date: Mon, 20 May 2024 07:58:51 +0800 Subject: [PATCH] =?UTF-8?q?opti=EF=BC=9A=E4=BC=98=E5=8C=96=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E9=94=99=E8=AF=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MainWidget.cpp | 5 ++++- src/config.cpp | 9 ++++++--- src/config.h | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/MainWidget.cpp b/MainWidget.cpp index cf4c774..6bddaf4 100644 --- a/MainWidget.cpp +++ b/MainWidget.cpp @@ -261,7 +261,10 @@ void MainWidget::judge_btn_page() void MainWidget::read(const QString& file_path) { - ini_.set_xml_path(file_path.toStdString()); + if (!ini_.set_xml_path(file_path.toStdString())) { + CUtil::msg(this, u8"没有ini配置文件或者保存ini失败。"); + return; + } ui->edStatus->setText(file_path); if (!xml_.open(base_.xml_path)) { diff --git a/src/config.cpp b/src/config.cpp index 563984a..ae82b18 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -19,13 +19,16 @@ bool ConfigIni::set_work_exe(const std::string& dir) return true; } -void ConfigIni::set_xml_path(const std::string& path) +bool ConfigIni::set_xml_path(const std::string& path) { if (ini_.IsEmpty()) { - return; + return false; } ini_.SetValue("Basic", "xml_path", path.c_str()); - ini_.SaveFile(ini_path_.c_str()); + if (!ini_.SaveFile(ini_path_.c_str()) != SI_OK) { + return false; + } + return true; } OprBase ConfigIni::get_config() diff --git a/src/config.h b/src/config.h index 8e1d33f..46b01c9 100644 --- a/src/config.h +++ b/src/config.h @@ -20,7 +20,7 @@ public: public: bool set_work_exe(const std::string& dir); - void set_xml_path(const std::string& path); + bool set_xml_path(const std::string& path); OprBase get_config(); private: