From 352d5ae046b0aafa9a476582ee6a2be9ef46c69d Mon Sep 17 00:00:00 2001 From: dayfine Date: Sat, 31 Oct 2026 08:46:49 -0700 Subject: [PATCH] Integrations: hold the Discord webhook finish callback in MoveOnlyFunction The webhook sender moves the callback into its scheduled send and never copies it. The send lambdas become mutable so they can call it. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- SerialPrograms/Source/Integrations/DiscordWebhook.cpp | 8 ++++---- SerialPrograms/Source/Integrations/DiscordWebhook.h | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/SerialPrograms/Source/Integrations/DiscordWebhook.cpp b/SerialPrograms/Source/Integrations/DiscordWebhook.cpp index 30e58621a6..fe7b187e5b 100644 --- a/SerialPrograms/Source/Integrations/DiscordWebhook.cpp +++ b/SerialPrograms/Source/Integrations/DiscordWebhook.cpp @@ -62,7 +62,7 @@ void DiscordWebhookSender::send( const QUrl& url, std::chrono::milliseconds delay, const JsonObject& obj, std::shared_ptr file, - std::function finish_callback + MoveOnlyFunction finish_callback ){ cleanup_stuck_requests(); std::shared_ptr json(new JsonValue(obj.clone())); @@ -75,7 +75,7 @@ void DiscordWebhookSender::send( json = std::move(json), file = std::move(file), finish_callback = std::move(finish_callback) - ]{ + ]() mutable{ throttle(); std::vector attachments; if (file){ @@ -95,7 +95,7 @@ void DiscordWebhookSender::send( const QUrl& url, std::chrono::milliseconds delay, const JsonObject& obj, std::vector> files, - std::function finish_callback + MoveOnlyFunction finish_callback ){ cleanup_stuck_requests(); std::shared_ptr json(new JsonValue(obj.clone())); @@ -108,7 +108,7 @@ void DiscordWebhookSender::send( json = std::move(json), files = std::move(files), finish_callback = std::move(finish_callback) - ]{ + ]() mutable{ throttle(); std::vector attachments; for (auto& file : files){ diff --git a/SerialPrograms/Source/Integrations/DiscordWebhook.h b/SerialPrograms/Source/Integrations/DiscordWebhook.h index 425d3ac7f3..c380e6a172 100644 --- a/SerialPrograms/Source/Integrations/DiscordWebhook.h +++ b/SerialPrograms/Source/Integrations/DiscordWebhook.h @@ -9,6 +9,7 @@ #include #include +#include "Common/Cpp/MoveOnlyFunction.h" #include "Common/Cpp/Time.h" #include "Common/Cpp/Concurrency/Mutex.h" #include "Common/Cpp/Concurrency/ConditionVariable.h" @@ -52,14 +53,14 @@ class DiscordWebhookSender : public QObject{ const QUrl& url, std::chrono::milliseconds delay, const JsonObject& obj, std::shared_ptr file, - std::function finish_callback = nullptr + MoveOnlyFunction finish_callback = nullptr ); void send( Logger& logger, const QUrl& url, std::chrono::milliseconds delay, const JsonObject& obj, std::vector> files, - std::function finish_callback = nullptr + MoveOnlyFunction finish_callback = nullptr ); static DiscordWebhookSender& instance();