From 94e8ce7551a01c71a0cbe0f041a85c89db52a06c Mon Sep 17 00:00:00 2001 From: Konrad Rosenbaum Date: Wed, 21 Dec 2016 23:56:44 +0100 Subject: [PATCH] fix crash Change-Id: I83d64f1b0071517d06d2b24e8a6c0ef48a720435 --- commonlib/misc/debug.cpp | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/commonlib/misc/debug.cpp b/commonlib/misc/debug.cpp index afab33f..53cec50 100644 --- a/commonlib/misc/debug.cpp +++ b/commonlib/misc/debug.cpp @@ -25,9 +25,11 @@ static QFile*mylogFile=0; static void mymsghandler(QtMsgType,const QMessageLogContext&, const QString&msg) { if(mylogFile){ - QByteArray data= - QDateTime::currentDateTime().toString("yyyy-MM-dd hh.mm.ss.zzz").toLatin1() +" "+ - msg.toLatin1()+"\n"; + QByteArray data; + //QDateTime::toString requires an active app object, otherwise it crashes + if(qApp) + data=QDateTime::currentDateTime().toString("yyyy-MM-dd hh.mm.ss.zzz").toLatin1() +" "; + data+=msg.toLatin1()+"\n"; mylogFile->write(data); mylogFile->flush(); } -- 1.7.2.5