From 54b6aee2e4ed33f79de48f7c1c2f5d793b88421f Mon Sep 17 00:00:00 2001 From: omigamedev Date: Mon, 15 Jun 2026 20:57:43 +0200 Subject: [PATCH] Extract cloud download thread helper --- docs/modernization/debt.md | 6 ++++++ docs/modernization/roadmap.md | 5 +++++ docs/modernization/tasks.md | 35 +++++++++++++++++++++++++++++++++++ src/legacy_cloud_services.cpp | 33 ++++++++++++++++++++------------- 4 files changed, 66 insertions(+), 13 deletions(-) diff --git a/docs/modernization/debt.md b/docs/modernization/debt.md index 554f8a19..b92fc19a 100644 --- a/docs/modernization/debt.md +++ b/docs/modernization/debt.md @@ -18,6 +18,12 @@ agent or engineer to remove them without reconstructing context from chat. ## Recent Reductions +- 2026-06-15: `DEBT-0038` was narrowed again. The retained cloud-download + detached worker body in `LegacyCloudServices::start_download()` now routes + through a focused helper in `src/legacy_cloud_services.cpp` instead of + living inline in the retained service method; the remaining cloud bridge + debt stays concentrated in retained prompt/progress lifetime, OpenGL context + guarding, and transfer-thread execution. - 2026-06-15: `DEBT-0038` was narrowed again. The retained cloud-browser thumbnail fetch, decode, and texture-apply path in `NodeDialogCloud::load_thumbs_thread()` now routes through a focused helper diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index fa5c9941..338da86b 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -129,6 +129,11 @@ The retained cloud-browser thumbnail fetch, decode, and texture-apply path in helper in `src/node_dialog_cloud.cpp`, so the remaining cloud bridge debt is further concentrated on prompt/progress lifetime, OpenGL context guarding, and transfer-thread execution. +The retained cloud-download detached worker body in +`LegacyCloudServices::start_download()` now also routes through a focused +helper in `src/legacy_cloud_services.cpp`, so the remaining cloud bridge debt +is further concentrated on prompt/progress lifetime, OpenGL context guarding, +and the still-retained transfer-thread execution model. Recent 2026-06-13 retained preview reductions continue to narrow DEBT-0036: `NodeStrokePreview::draw_stroke_immediate()` now also routes diff --git a/docs/modernization/tasks.md b/docs/modernization/tasks.md index f7aa393e..48a88185 100644 --- a/docs/modernization/tasks.md +++ b/docs/modernization/tasks.md @@ -696,6 +696,41 @@ Completed Task Log: | --- | --- | ---: | --- | --- | | 2026-06-15 | ADP-017 | no score movement | `MSBuild.exe out\build\windows-msvc-default\panopainter_app.vcxproj /p:Configuration=Debug /p:Platform=x64`; `ctest --preset desktop-fast --build-config Debug -R "pp_app_core_document_cloud" --output-on-failure` | `9b6fe73a` | +### ADP-018 - Extract Cloud Download Thread Helper + +Status: Done +Score: no score movement +Debt: `DEBT-0038` +Scope: `src/legacy_cloud_services.cpp` only + +Goal: + +Reduce the inline retained cloud-download worker surface by extracting the +detached `LegacyCloudServices::start_download()` thread body into a focused +helper while preserving current behavior. + +Done Checks: + +- The detached cloud-download worker body no longer lives inline in + `LegacyCloudServices::start_download()`. +- The retained download-thread execution path now routes through a focused + helper in `src/legacy_cloud_services.cpp`. +- `DEBT-0038` and the roadmap note the reduced remaining cloud bridge + surface. + +Validation: + +```powershell +& 'C:\Program Files\Microsoft Visual Studio\18\Community\MSBuild\Current\Bin\MSBuild.exe' out\build\windows-msvc-default\panopainter_app.vcxproj /p:Configuration=Debug /p:Platform=x64 +ctest --preset desktop-fast --build-config Debug -R "pp_app_core_document_cloud" --output-on-failure +``` + +Completed Task Log: + +| Date | Task | Score | Validation | Commit | +| --- | --- | ---: | --- | --- | +| 2026-06-15 | ADP-018 | no score movement | `MSBuild.exe out\build\windows-msvc-default\panopainter_app.vcxproj /p:Configuration=Debug /p:Platform=x64`; `ctest --preset desktop-fast --build-config Debug -R "pp_app_core_document_cloud" --output-on-failure` | `(pending)` | + Completed Task Log: | Date | Task | Score | Validation | Commit | diff --git a/src/legacy_cloud_services.cpp b/src/legacy_cloud_services.cpp index 01808577..6ccfb416 100644 --- a/src/legacy_cloud_services.cpp +++ b/src/legacy_cloud_services.cpp @@ -151,6 +151,25 @@ void execute_cloud_upload_transfer( curl_easy_cleanup(curl); } } + +void execute_cloud_download_thread( + App& app, + const pp::app::CloudDownloadRequest& request) +{ + BT_SetTerminate(); + + auto m = pp::panopainter::create_legacy_app_message_dialog( + app, + pp::app::plan_cloud_download_progress_prompt()); + std::string url = "https://panopainter.com/cloud/cloud-dwl.php?file=" + request.selected_file; + execute_cloud_download_transfer(app, url, request.selected_path, [m](float p) { + const auto progress = pp::app::format_cloud_download_progress_message(p); + m->m_message->set_text(progress.c_str()); + }); + + execute_legacy_downloaded_project_open(app, request.selected_path, request.selected_name); + pp::panopainter::close_legacy_dialog_node(*m); +} #endif //WITH_CURL class LegacyCloudServices final : public pp::app::CloudServices { @@ -249,19 +268,7 @@ public: { auto* app = &app_; std::thread([app, request] { - BT_SetTerminate(); - - auto m = pp::panopainter::create_legacy_app_message_dialog( - *app, - pp::app::plan_cloud_download_progress_prompt()); - std::string url = "https://panopainter.com/cloud/cloud-dwl.php?file=" + request.selected_file; - execute_cloud_download_transfer(*app, url, request.selected_path, [m](float p) { - const auto progress = pp::app::format_cloud_download_progress_message(p); - m->m_message->set_text(progress.c_str()); - }); - - execute_legacy_downloaded_project_open(*app, request.selected_path, request.selected_name); - pp::panopainter::close_legacy_dialog_node(*m); + execute_cloud_download_thread(*app, request); }).detach(); }