fix crash
authorKonrad Rosenbaum <konrad@silmor.de>
Wed, 21 Dec 2016 22:56:44 +0000 (23:56 +0100)
committerKonrad Rosenbaum <konrad@silmor.de>
Wed, 21 Dec 2016 22:56:44 +0000 (23:56 +0100)
Change-Id: I83d64f1b0071517d06d2b24e8a6c0ef48a720435

commonlib/misc/debug.cpp

index afab33f..53cec50 100644 (file)
@@ -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();
         }