Skip to content

Commit

Permalink
libdeng2: Fixed crash when doing log output during atexit()
Browse files Browse the repository at this point in the history
The log buffer has already been destroyed when atexit calls its
callbacks.
  • Loading branch information
skyjake committed Mar 23, 2013
1 parent c35524e commit a89fcc0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions doomsday/libdeng2/include/de/core/logbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ class DENG2_PUBLIC LogBuffer : public QObject, public Lockable, DENG2_OBSERVES(F

static LogBuffer &appBuffer();

static bool isAppBufferAvailable();

public slots:
/**
* Flushes all unflushed entries to the defined outputs.
Expand Down
3 changes: 2 additions & 1 deletion doomsday/libdeng2/src/core/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,8 @@ void Log::disposeThreadLog()

LogEntryStager::LogEntryStager(LogEntry::Level level, String const &format) : _level(level)
{
_disabled = !LogBuffer::appBuffer().isEnabled(level);
_disabled = !LogBuffer::isAppBufferAvailable() ||
!LogBuffer::appBuffer().isEnabled(level);
if(!_disabled)
{
_format = format;
Expand Down
7 changes: 7 additions & 0 deletions doomsday/libdeng2/src/core/logbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ LogBuffer::~LogBuffer()

setOutputFile("");
clear();

if(_appBuffer == this) _appBuffer = 0;
}

void LogBuffer::clear()
Expand Down Expand Up @@ -316,4 +318,9 @@ LogBuffer &LogBuffer::appBuffer()
return *_appBuffer;
}

bool LogBuffer::isAppBufferAvailable()
{
return _appBuffer != 0;
}

} // namespace de

0 comments on commit a89fcc0

Please sign in to comment.