From ca63dd3bb9114ce07ba24739325036c17ad15729 Mon Sep 17 00:00:00 2001 From: smlee Date: Thu, 12 Feb 2015 15:41:13 +0900 Subject: [PATCH] fix libsigc++ crash --- lib/base/eerror.cpp | 25 +++++++++++++++++-------- lib/base/eerror.h | 1 + lib/base/init.cpp | 3 +++ main/bsod.cpp | 2 +- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/lib/base/eerror.cpp b/lib/base/eerror.cpp index 35e46e0..e294970 100644 --- a/lib/base/eerror.cpp +++ b/lib/base/eerror.cpp @@ -72,6 +72,7 @@ void DumpUnfreed() }; #endif +SigC::Connection logConnection; Signal2 logOutput; int logOutputConsole=1; @@ -103,8 +104,10 @@ void eDebug(const char* fmt, ...) va_start(ap, fmt); vsnprintf(buf, 1024, fmt, ap); va_end(ap); - singleLock s(DebugLock); - logOutput(lvlDebug, std::string(buf) + "\n"); + if (logConnection.connected()) { + singleLock s(DebugLock); + logOutput(lvlDebug, std::string(buf) + "\n"); + } if (logOutputConsole) fprintf(stderr, "%s\n", buf); } @@ -116,8 +119,10 @@ void eDebugNoNewLine(const char* fmt, ...) va_start(ap, fmt); vsnprintf(buf, 1024, fmt, ap); va_end(ap); - singleLock s(DebugLock); - logOutput(lvlDebug, buf); + if (logConnection.connected()) { + singleLock s(DebugLock); + logOutput(lvlDebug, buf); + } if (logOutputConsole) fprintf(stderr, "%s", buf); } @@ -129,8 +134,10 @@ void eWarning(const char* fmt, ...) va_start(ap, fmt); vsnprintf(buf, 1024, fmt, ap); va_end(ap); - singleLock s(DebugLock); - logOutput(lvlWarning, std::string(buf) + "\n"); + if (logConnection.connected()) { + singleLock s(DebugLock); + logOutput(lvlWarning, std::string(buf) + "\n"); + } if (logOutputConsole) fprintf(stderr, "%s\n", buf); } @@ -139,8 +146,10 @@ void eWarning(const char* fmt, ...) void ePythonOutput(const char *string) { #ifdef DEBUG - singleLock s(DebugLock); - logOutput(lvlWarning, string); + if (logConnection.connected()) { + singleLock s(DebugLock); + logOutput(lvlWarning, string); + } if (logOutputConsole) fwrite(string, 1, strlen(string), stderr); #endif diff --git a/lib/base/eerror.h b/lib/base/eerror.h index 6040565..249c2a0 100644 --- a/lib/base/eerror.h +++ b/lib/base/eerror.h @@ -109,6 +109,7 @@ void DumpUnfreed(); #define CHECKFORMAT __attribute__ ((__format__(__printf__, 1, 2))) +extern SigC::Connection logConnection; extern Signal2 logOutput; extern int logOutputConsole; diff --git a/lib/base/init.cpp b/lib/base/init.cpp index b9cf1de..203accb 100644 --- a/lib/base/init.cpp +++ b/lib/base/init.cpp @@ -32,6 +32,9 @@ eInit::~eInit() setRunlevel(-1); delete cl; cl=0; + if (logConnection.connected()) { + logConnection.disconnect(); + } } void eInit::setRunlevel(int nrl) diff --git a/main/bsod.cpp b/main/bsod.cpp index 82bd73d..4c056b3 100644 --- a/main/bsod.cpp +++ b/main/bsod.cpp @@ -320,5 +320,5 @@ void bsodCatchSignals() void bsodLogInit() { - logOutput.connect(addToLogbuffer); + logConnection = logOutput.connect(addToLogbuffer); } -- 2.7.4