Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2014-05-26 15:01:29 +0400
committerOlivier Goffart <ogoffart@woboq.com>2014-05-26 16:37:14 +0400
commit50ce0f9681638176aa6a7cf0edd9c482a7b07e2f (patch)
tree4a70c365ed987ed999520bc793b749446094bb4c /src/mirall/logger.cpp
parenta60902b33d78d4c951f90e01b004bbdc3e7e6eff (diff)
Fix crash at exit when there is a log after the Logger has been destroyed
Use a proper static Logger instead of allocating one, and cleanup the QTMessageLogger when it is destroyed
Diffstat (limited to 'src/mirall/logger.cpp')
-rw-r--r--src/mirall/logger.cpp33
1 files changed, 12 insertions, 21 deletions
diff --git a/src/mirall/logger.cpp b/src/mirall/logger.cpp
index 6c8561908..0bc8d1ccb 100644
--- a/src/mirall/logger.cpp
+++ b/src/mirall/logger.cpp
@@ -27,6 +27,9 @@ static void mirallLogCatcher(QtMsgType type, const char *msg)
// qDebug() exports to local8Bit, which is not always UTF-8
Logger::instance()->mirallLog( QString::fromLocal8Bit(msg) );
}
+static void qInstallMessageHandler(QtMsgHandler h) {
+ qInstallMsgHandler(h);
+}
#else
static void mirallLogCatcher(QtMsgType, const QMessageLogContext &ctx, const QString &message) {
Q_UNUSED(ctx);
@@ -38,35 +41,23 @@ static void mirallLogCatcher(QtMsgType, const QMessageLogContext &ctx, const QSt
}
#endif
-Logger* Logger::_instance=0;
-
-Logger::Logger( QObject* parent)
-: QObject(parent),
- _showTime(true), _doLogging(false), _doFileFlush(false), _logExpire(0)
+Logger *Logger::instance()
{
+ static Logger log;
+ return &log;
}
-Logger *Logger::instance()
+Logger::Logger( QObject* parent) : QObject(parent),
+ _showTime(true), _doLogging(false), _doFileFlush(false), _logExpire(0)
{
- if( !Logger::_instance ) {
- Logger::_instance = new Logger;
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- qInstallMsgHandler( mirallLogCatcher );
-#else
- qInstallMessageHandler(mirallLogCatcher);
-#endif
- }
- return Logger::_instance;
+ qInstallMessageHandler(mirallLogCatcher);
}
-void Logger::destroy()
-{
- if( Logger::_instance ) {
- delete Logger::_instance;
- Logger::_instance = 0;
- }
+Logger::~Logger() {
+ qInstallMessageHandler(0);
}
+
void Logger::postGuiLog(const QString &title, const QString &message)
{
emit guiLog(title, message);