From da1e671d4285fce4b2b1603be90afc652c4f4b65 Mon Sep 17 00:00:00 2001 From: gabime Date: Sat, 17 Jun 2023 18:09:08 +0300 Subject: [PATCH] Clean qt_color_sink --- include/spdlog/sinks/qt_sinks.h | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/include/spdlog/sinks/qt_sinks.h b/include/spdlog/sinks/qt_sinks.h index 6c0c7c24..14a95bcc 100644 --- a/include/spdlog/sinks/qt_sinks.h +++ b/include/spdlog/sinks/qt_sinks.h @@ -157,26 +157,24 @@ private: memory_buf_t formatted; base_sink::formatter_->format(msg, formatted); - string_view_t str = string_view_t(formatted.data(), formatted.size()); + const string_view_t str = string_view_t(formatted.data(), formatted.size()); // apply the color to the color range in the formatted message. auto payload = QString::fromLatin1(str.data(), static_cast(str.size())); - // if color needed, apply it as - //if (msg.color_range_end > msg.color_range_start) - { - invoke_params params { - max_lines_, // max lines - qt_text_edit_, // text edit to append to - std::move(payload), // text to append - default_color_, // default color - colors_.at(msg.level), // color to apply - msg.color_range_start, // color range start - msg.color_range_end}; // color range end - QMetaObject::invokeMethod( - qt_text_edit_, - [params]() {invoke_method_(params);}, - Qt::AutoConnection); - } + invoke_params params { + max_lines_, // max lines + qt_text_edit_, // text edit to append to + std::move(payload), // text to append + default_color_, // default color + colors_.at(msg.level), // color to apply + msg.color_range_start, // color range start + msg.color_range_end}; // color range end + + QMetaObject::invokeMethod( + qt_text_edit_, + [params]() {invoke_method_(params);}, + Qt::AutoConnection); + } void flush_() override {}