Skip to content

Commit a273001

Browse files
committed
添加 FlutterViewController 创建的异常处理和输出刷新,修复日志脚本编码问题
1 parent 9b0efcd commit a273001

2 files changed

Lines changed: 24 additions & 6 deletions

File tree

windows/runner/flutter_window.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,28 @@ bool FlutterWindow::OnCreate() {
3030
// The size here must match the window dimensions to avoid unnecessary surface
3131
// creation / destruction in the startup path.
3232
printf("[FlutterWindow] 创建 FlutterViewController...\n");
33-
flutter_controller_ = std::make_unique<flutter::FlutterViewController>(
34-
frame.right - frame.left, frame.bottom - frame.top, project_);
33+
printf("[FlutterWindow] 窗口尺寸: %d x %d\n",
34+
frame.right - frame.left, frame.bottom - frame.top);
35+
36+
try {
37+
flutter_controller_ = std::make_unique<flutter::FlutterViewController>(
38+
frame.right - frame.left, frame.bottom - frame.top, project_);
39+
printf("[FlutterWindow] FlutterViewController 创建成功\n");
40+
} catch (const std::exception& e) {
41+
printf("[FlutterWindow] 异常: 创建 FlutterViewController 时发生异常: %s\n", e.what());
42+
return false;
43+
} catch (...) {
44+
printf("[FlutterWindow] 异常: 创建 FlutterViewController 时发生未知异常\n");
45+
return false;
46+
}
3547

3648
// Ensure that basic setup of the controller was successful.
49+
if (!flutter_controller_) {
50+
printf("[FlutterWindow] 错误: FlutterController 指针为空\n");
51+
return false;
52+
}
53+
54+
printf("[FlutterWindow] 检查 Flutter 引擎...\n");
3755
if (!flutter_controller_->engine()) {
3856
printf("[FlutterWindow] 错误: Flutter 引擎为空\n");
3957
return false;

查看Windows日志-详细.bat

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ echo ========================================
44
echo 小纯观影馆 - Windows 详细日志查看工具
55
echo ========================================
66
echo.
7-
echo 此脚本将
8-
echo 1. 检查所有必需文件
9-
echo 2. 显示环境信息
10-
echo 3. 启动应用并显示所有日志
7+
echo 此脚本将执行以下操作
8+
echo 1. 检查所有必需文件
9+
echo 2. 显示环境信息
10+
echo 3. 启动应用并显示所有日志
1111
echo.
1212
echo 按 Ctrl+C 可以停止应用和日志查看
1313
echo.

0 commit comments

Comments
 (0)