Skip to content

Commit e909bad

Browse files
committed
fix getLogString, flush fatal log stream.
1 parent 4e5655a commit e909bad

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

fatal.cc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
#include <cstdio> // for vsnprintf
2424
#include <cstdlib> // for exit
2525

26-
#include <QByteArray> // for QByteArray
2726
#include <QDebug> // for QDebug
27+
#include <QString> // for QString
2828
#include <QtGlobal> // for qCritical, qDebug, qInfo, qWarning
2929

3030
#include "defs.h" // for DebugLog, gbFatal, gbDebug, gbInfo, gbWarning
@@ -59,6 +59,7 @@ gbFatal(const char* fmt, ...)
5959
va_list args;
6060
va_start(args, fmt);
6161
gbVLog(QtCriticalMsg, fmt, args);
62+
gbFlush(QtCriticalMsg);
6263
va_end(args);
6364
exit(1);
6465
}
@@ -97,24 +98,23 @@ static QString gbCriticalLogString_;
9798

9899
static QString& getLogString(QtMsgType type)
99100
{
100-
QString& logString = gbDebugLogString_;
101101
switch (type)
102102
{
103103
case QtDebugMsg:
104-
logString = gbDebugLogString_;
104+
return gbDebugLogString_;
105105
break;
106106
case QtInfoMsg:
107-
logString = gbInfoLogString_;
107+
return gbInfoLogString_;
108108
break;
109109
case QtWarningMsg:
110-
logString = gbWarningLogString_;
110+
return gbWarningLogString_;
111111
break;
112112
case QtCriticalMsg:
113113
case QtFatalMsg:
114-
logString = gbCriticalLogString_;
114+
default:
115+
return gbCriticalLogString_;
115116
break;
116117
}
117-
return logString;
118118
}
119119

120120
static void sendLogMsg(QtMsgType type, const QString& msg)
@@ -132,6 +132,7 @@ static void sendLogMsg(QtMsgType type, const QString& msg)
132132
break;
133133
case QtCriticalMsg:
134134
case QtFatalMsg:
135+
default:
135136
qCritical().noquote() << msg;
136137
break;
137138
}

0 commit comments

Comments
 (0)