From 32701af60bbf0cde6c9e69a5aff4517cf89e85f7 Mon Sep 17 00:00:00 2001 From: Ulmo-F Date: Tue, 6 Jun 2023 18:53:10 +0200 Subject: [PATCH] qt_sink: add some warning on its usage (#2753) * qt_sink: add some warning on its usage * qt_sink: add some warning on its usage - fix --------- Co-authored-by: Benoit FANCHON --- include/spdlog/sinks/qt_sinks.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/spdlog/sinks/qt_sinks.h b/include/spdlog/sinks/qt_sinks.h index 31b49c60..4f41728b 100644 --- a/include/spdlog/sinks/qt_sinks.h +++ b/include/spdlog/sinks/qt_sinks.h @@ -55,25 +55,35 @@ private: #include "spdlog/details/null_mutex.h" #include +// Warning: qt_sink won't be notified if the target QObject is destroyed. +// If the object's lifetime can be shorter than the logger's one, you should provide some permanent object and then use a standard signal/slot. using qt_sink_mt = qt_sink; +// Warning: qt_sink won't be notified if the target QObject is destroyed. +// If the object's lifetime can be shorter than the logger's one, you should provide some permanent object and then use a standard signal/slot. using qt_sink_st = qt_sink; } // namespace sinks // // Factory functions // +// Warning: the qt_sink won't be notified if the target widget is destroyed. +// If the widget's lifetime can be shorter than the logger's one, you should provide some permanent QObject and then use a standard signal/slot. template inline std::shared_ptr qt_logger_mt(const std::string &logger_name, QTextEdit *qt_object, const std::string &meta_method = "append") { return Factory::template create(logger_name, qt_object, meta_method); } +// Warning: the qt_sink won't be notified if the target widget is destroyed. +// If the widget's lifetime can be shorter than the logger's one, you should provide some permanent QObject and then use a standard signal/slot. template inline std::shared_ptr qt_logger_st(const std::string &logger_name, QTextEdit *qt_object, const std::string &meta_method = "append") { return Factory::template create(logger_name, qt_object, meta_method); } +// Warning: the qt_sink won't be notified if the target QObject is destroyed. +// If the object's lifetime can be shorter than the logger's one, you should provide some permanent QObject and then use a standard signal/slot. template inline std::shared_ptr qt_logger_mt( const std::string &logger_name, QPlainTextEdit *qt_object, const std::string &meta_method = "appendPlainText") @@ -81,6 +91,8 @@ inline std::shared_ptr qt_logger_mt( return Factory::template create(logger_name, qt_object, meta_method); } +// Warning: the qt_sink won't be notified if the target widget is destroyed. +// If the widget's lifetime can be shorter than the logger's one, you should provide some permanent QObject and then use a standard signal/slot. template inline std::shared_ptr qt_logger_st( const std::string &logger_name, QPlainTextEdit *qt_object, const std::string &meta_method = "appendPlainText") @@ -88,12 +100,16 @@ inline std::shared_ptr qt_logger_st( return Factory::template create(logger_name, qt_object, meta_method); } +// Warning: the qt_sink won't be notified if the target QObject is destroyed. +// If the objet's lifetime can be shorter than the logger's one, you should provide some permanent QObject and then use a standard signal/slot. template inline std::shared_ptr qt_logger_mt(const std::string &logger_name, QObject *qt_object, const std::string &meta_method) { return Factory::template create(logger_name, qt_object, meta_method); } +// Warning: the qt_sink won't be notified if the target QObject is destroyed. +// If the objet's lifetime can be shorter than the logger's one, you should provide some permanent QObject and then use a standard signal/slot. template inline std::shared_ptr qt_logger_st(const std::string &logger_name, QObject *qt_object, const std::string &meta_method) {