From 14b23d17e7f11a3d48b230f400f113a3d1f4f7aa Mon Sep 17 00:00:00 2001 From: Michael de Lang Date: Mon, 28 Oct 2024 23:10:41 +0100 Subject: [PATCH] Ensure flush callback gets called in move-assign operator --- include/spdlog/details/thread_pool.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/spdlog/details/thread_pool.h b/include/spdlog/details/thread_pool.h index 4d7e1d751..846613716 100644 --- a/include/spdlog/details/thread_pool.h +++ b/include/spdlog/details/thread_pool.h @@ -49,12 +49,12 @@ struct async_msg : log_msg_buffer { flush_callback(std::move(other.flush_callback)) { other.flush_callback = nullptr; } + async_msg &operator=(async_msg &&other) SPDLOG_NOEXCEPT { *static_cast(this) = static_cast(other); msg_type = other.msg_type; worker_ptr = std::move(other.worker_ptr); - flush_callback = std::move(other.flush_callback); - other.flush_callback = nullptr; + std::swap(flush_callback, other.flush_callback); return *this; }