// ============================================================================ // main —— Day4 Mandelbrot 分形渲染器入口 // offscreen 平台(QT_QPA_PLATFORM=offscreen)下:show 触发首帧后台渲染, // 200ms 后退出;aboutToQuit 等线程池收尾,避免悬垂任务访问已析构对象。 // 仓库自动化验证据此断言退出码 0(CLAUDE.md 行为风格第 2 点)。 // ============================================================================ #include #include #include #include #include "mandelbrot_widget.h" int main(int argc, char* argv[]) { QApplication app(argc, argv); MandelbrotWidget w; w.resize(820, 640); w.setWindowTitle(QStringLiteral("Day4 · Mandelbrot 分形渲染器(绘图 / 多线程 / 事件)")); w.show(); if (app.platformName() == QStringLiteral("offscreen")) { // 等所有在途 QRunnable 跑完,再让 widget 析构(任务持值副本,但仍可能 // 通过排队信号访问 this——这里确保它们落定)。 QObject::connect(&app, &QCoreApplication::aboutToQuit, []() { QThreadPool::globalInstance()->waitForDone(); }); QTimer::singleShot(200, &app, &QApplication::quit); } return app.exec(); }