From 07499f66581d7dec98620c828cb8685e103c8724 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 14 May 2013 16:23:53 +0000 Subject: [PATCH] From Lionel Lagarde, "When a function do: OSG_DEBUG << "Hello world!\n"; the underlying stream is not automatically flushed. It is flushed if endl is queued instead of \n: OSG_DEBUG << "Hello world!" << std::endl; The notify macros do: stream->setCurrentSeverity(severity); return *stream; So, if a function do: OSG_DEBUG << "This is a debug message\n"; OSG_NOTICE << "This is a notice message" << std::endl; the debug message will be classified as a notice message. It is a problem when the application uses a NotifyHandler. The notify method of the handler is called with: severity = NOTICE message = "This is a debug message\nThis is a notice message" The attached Notify.cpp contains an automatic flush of the stream when the current severity changes. " --- src/osg/Notify.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/osg/Notify.cpp b/src/osg/Notify.cpp index 59b232aec..199336c0d 100644 --- a/src/osg/Notify.cpp +++ b/src/osg/Notify.cpp @@ -65,7 +65,15 @@ struct NotifyStreamBuffer : public std::stringbuf osg::NotifyHandler *getNotifyHandler() const { return _handler.get(); } /** Sets severity for next call of notify handler */ - void setCurrentSeverity(osg::NotifySeverity severity) { _severity = severity; } + void setCurrentSeverity(osg::NotifySeverity severity) + { + if (_severity != severity) + { + sync(); + _severity = severity; + } + } + osg::NotifySeverity getCurrentSeverity() const { return _severity; } private: