diff --git a/include/spdlog/sinks/qt_sinks.h b/include/spdlog/sinks/qt_sinks.h index 31b49c60..85114b48 100644 --- a/include/spdlog/sinks/qt_sinks.h +++ b/include/spdlog/sinks/qt_sinks.h @@ -25,6 +25,8 @@ template class qt_sink : public base_sink { public: + // 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. qt_sink(QObject *qt_object, const std::string &meta_method) { qt_object_ = qt_object; @@ -62,18 +64,24 @@ using qt_sink_st = qt_sink; // // 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 +89,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 +98,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) {