From 33ae22ce6289bce89325c077fa4784e031e9b87c Mon Sep 17 00:00:00 2001 From: impressionyang Date: Wed, 13 May 2026 14:36:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=97=B6=E6=9C=BA=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E5=9C=A8=E9=85=8D=E7=BD=AE=E5=8A=A0=E8=BD=BD=E5=90=8E=E6=89=8D?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Application 构造函数中调用 loadGlobalModel() 时,配置文件 尚未加载,导致模型路径始终为空。改为将 loadGlobalModel() 设为 公开方法,在 main() 中配置加载和命令行参数处理完成后显式调用。 Co-Authored-By: Claude Opus 4.6 --- src/app/application.cpp | 3 --- src/app/application.h | 5 +++-- src/main.cpp | 3 +++ 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/app/application.cpp b/src/app/application.cpp index 4f8f1a4..e047f69 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -29,9 +29,6 @@ Application::Application(int& argc, char** argv) LOG_ERROR(kTag, QString("全局模型加载失败: %1").arg(err)); emit modelLoadError(err); }); - - // 异步加载全局模型 - loadGlobalModel(); } Application::~Application() { diff --git a/src/app/application.h b/src/app/application.h index a8ac9ae..b30f48e 100644 --- a/src/app/application.h +++ b/src/app/application.h @@ -32,6 +32,9 @@ public: /** @brief 获取全局 STT 引擎加载状态 */ bool isModelLoaded() const; + /** @brief 加载全局模型(在配置加载后手动调用) */ + void loadGlobalModel(); + signals: /** @brief 模型加载中(带路径) */ void modelLoading(const QString& modelPath); @@ -43,8 +46,6 @@ signals: void modelLoadError(const QString& error); private: - void loadGlobalModel(); - std::unique_ptr configManager_; SenseVoiceEngine* sttEngine_ = nullptr; QString modelPath_; diff --git a/src/main.cpp b/src/main.cpp index 10f99b5..bd482ec 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -56,6 +56,9 @@ int main(int argc, char* argv[]) configManager->set("stt.model_path", modelPath); } + // 配置加载完成后,启动全局模型加载 + app.loadGlobalModel(); + // 创建并显示主窗口(传入全局引擎) impress::MainWindow mainWindow(configManager, app.sttEngine()); mainWindow.show();