diff --git a/doomsday/libdeng2/include/de/core/log.h b/doomsday/libdeng2/include/de/core/log.h index 7c765dfa8b..747404d079 100644 --- a/doomsday/libdeng2/include/de/core/log.h +++ b/doomsday/libdeng2/include/de/core/log.h @@ -270,7 +270,7 @@ class DENG2_PUBLIC Log * * @ingroup core */ -class DENG2_PUBLIC LogEntry +class DENG2_PUBLIC LogEntry : public Lockable { public: /** @@ -434,7 +434,9 @@ class DENG2_PUBLIC LogEntry template inline LogEntry &operator << (ValueType const &v) { if(!_disabled) { + lock(); _args.push_back(new Arg(v)); + unlock(); } return *this; } diff --git a/doomsday/libdeng2/src/core/log.cpp b/doomsday/libdeng2/src/core/log.cpp index fcca5f5cd4..5b59ccd727 100644 --- a/doomsday/libdeng2/src/core/log.cpp +++ b/doomsday/libdeng2/src/core/log.cpp @@ -21,6 +21,7 @@ #include "de/Time" #include "de/Date" #include "de/LogBuffer" +#include "de/Guard" #include "logtextstyle.h" #include @@ -76,6 +77,8 @@ LogEntry::LogEntry(Log::LogLevel level, String const §ion, int sectionDepth, LogEntry::~LogEntry() { + DENG2_GUARD(this); // cannot delete if someone has a lock + for(Args::iterator i = _args.begin(); i != _args.end(); ++i) { delete *i; @@ -84,6 +87,8 @@ LogEntry::~LogEntry() String LogEntry::asText(Flags const &formattingFlags, int shortenSection) const { + DENG2_GUARD(this); // others shouldn't touch the entry while we're converting + /// @todo This functionality belongs in an entry formatter class. Flags flags = formattingFlags;