From b6da59447f165ad70a4e3ca1c575b14ea66d92c9 Mon Sep 17 00:00:00 2001 From: Michael de Lang Date: Wed, 30 Oct 2024 16:55:45 +0100 Subject: [PATCH] Ensure flush callback gets called in move-assign operator (#3232) --- 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 4d7e1d75..84661371 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; }