From 2ccba49b0169091806360ecd3abc8e1ba5f4936d Mon Sep 17 00:00:00 2001 From: Muhammed Galib Uludag Date: Wed, 28 Jul 2021 00:06:12 +0300 Subject: [PATCH] removed nullptr checks and renamed member vars --- include/spdlog/sinks/qt_sinks.h | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/include/spdlog/sinks/qt_sinks.h b/include/spdlog/sinks/qt_sinks.h index 8cddec72..50d39084 100644 --- a/include/spdlog/sinks/qt_sinks.h +++ b/include/spdlog/sinks/qt_sinks.h @@ -26,7 +26,7 @@ class qtextedit_sink : public base_sink { public: qtextedit_sink(QTextEdit *textedit = nullptr) { if (textedit != nullptr) { - qtextedit = textedit; + qtextedit_ = textedit; } else { throw spdlog_ex("Error opening QTextEdit"); } @@ -36,18 +36,16 @@ public: protected: void sink_it_(const details::log_msg &msg) override { - if(qtextedit == nullptr) - return; memory_buf_t formatted; base_sink::formatter_->format(msg, formatted); string_view_t str = string_view_t(formatted.data(), formatted.size()); - QMetaObject::invokeMethod(qtextedit,"append", Qt::AutoConnection, Q_ARG(QString, QString::fromUtf8(str.data(), static_cast(str.size())).trimmed())); + QMetaObject::invokeMethod(qtextedit_,"append", Qt::AutoConnection, Q_ARG(QString, QString::fromUtf8(str.data(), static_cast(str.size())).trimmed())); } void flush_() override {} private: - QTextEdit* qtextedit = nullptr; + QTextEdit* qtextedit_ = nullptr; }; // @@ -58,7 +56,7 @@ class qplaintextedit_sink : public base_sink { public: qplaintextedit_sink(QPlainTextEdit *textedit = nullptr) { if (textedit != nullptr) { - qplaintextedit = textedit; + qplaintextedit_ = textedit; } else { throw spdlog_ex("Error opening QPlainTextEdit"); } @@ -68,18 +66,16 @@ public: protected: void sink_it_(const details::log_msg &msg) override { - if(qplaintextedit == nullptr) - return; memory_buf_t formatted; base_sink::formatter_->format(msg, formatted); string_view_t str = string_view_t(formatted.data(), formatted.size()); - QMetaObject::invokeMethod(qplaintextedit, "appendPlainText", Qt::AutoConnection, Q_ARG(QString, QString::fromUtf8(str.data(), static_cast(str.size())).trimmed())); + QMetaObject::invokeMethod(qplaintextedit_, "appendPlainText", Qt::AutoConnection, Q_ARG(QString, QString::fromUtf8(str.data(), static_cast(str.size())).trimmed())); } void flush_() override {} private: - QPlainTextEdit* qplaintextedit = nullptr; + QPlainTextEdit* qplaintextedit_ = nullptr; }; #include "spdlog/details/null_mutex.h"