Save log to file. Send or collect after crash (only Windows).
--HG-- branch : develop
This commit is contained in:
parent
399706237d
commit
8c908f84ee
|
@ -43,6 +43,97 @@
|
||||||
#include <QUndoStack>
|
#include <QUndoStack>
|
||||||
#include <QtCore/qmath.h>
|
#include <QtCore/qmath.h>
|
||||||
#include <QTemporaryFile>
|
#include <QTemporaryFile>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||||
|
{
|
||||||
|
// Why on earth didn't Qt want to make failed signal/slot connections qWarning?
|
||||||
|
if ((type == QtDebugMsg) && msg.contains("::connect"))
|
||||||
|
{
|
||||||
|
type = QtWarningMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
// this is another one that doesn't make sense as just a debug message. pretty serious
|
||||||
|
// sign of a problem
|
||||||
|
// http://www.developer.nokia.com/Community/Wiki/QPainter::begin:Paint_device_returned_engine_%3D%3D_0_(Known_Issue)
|
||||||
|
if ((type == QtDebugMsg) && msg.contains("QPainter::begin") && msg.contains("Paint device returned engine"))
|
||||||
|
{
|
||||||
|
type = QtWarningMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This qWarning about "Cowardly refusing to send clipboard message to hung application..."
|
||||||
|
// is something that can easily happen if you are debugging and the application is paused.
|
||||||
|
// As it is so common, not worth popping up a dialog.
|
||||||
|
if ((type == QtWarningMsg) && QString(msg).contains("QClipboard::event")
|
||||||
|
&& QString(msg).contains("Cowardly refusing"))
|
||||||
|
{
|
||||||
|
type = QtDebugMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
// only the GUI thread should display message boxes. If you are
|
||||||
|
// writing a multithreaded application and the error happens on
|
||||||
|
// a non-GUI thread, you'll have to queue the message to the GUI
|
||||||
|
QCoreApplication *instance = QCoreApplication::instance();
|
||||||
|
const bool isGuiThread = instance && (QThread::currentThread() == instance->thread());
|
||||||
|
|
||||||
|
if (isGuiThread)
|
||||||
|
{
|
||||||
|
QString debugdate = QDateTime::currentDateTime().toString("yyyy.MM.dd hh:mm:ss");
|
||||||
|
QMessageBox messageBox;
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case QtDebugMsg:
|
||||||
|
debugdate += QString(" [Debug] %1: %2 (%3:%4, %5)").arg(context.category).arg(msg).arg(context.file)
|
||||||
|
.arg(context.line).arg(context.function);
|
||||||
|
break;
|
||||||
|
case QtWarningMsg:
|
||||||
|
debugdate += QString(" [Warning] %1: %2 (%3:%4, %5)").arg(context.category).arg(msg).arg(context.file)
|
||||||
|
.arg(context.line).arg(context.function);
|
||||||
|
messageBox.setIcon(QMessageBox::Warning);
|
||||||
|
messageBox.setInformativeText(msg);
|
||||||
|
messageBox.setStandardButtons(QMessageBox::Ok);
|
||||||
|
messageBox.exec();
|
||||||
|
break;
|
||||||
|
case QtCriticalMsg:
|
||||||
|
debugdate += QString(" [Critical] %1: %2 (%3:%4, %5)").arg(context.category).arg(msg).arg(context.file)
|
||||||
|
.arg(context.line).arg(context.function);
|
||||||
|
messageBox.setIcon(QMessageBox::Critical);
|
||||||
|
messageBox.setInformativeText(msg);
|
||||||
|
messageBox.setStandardButtons(QMessageBox::Ok);
|
||||||
|
messageBox.exec();
|
||||||
|
break;
|
||||||
|
case QtFatalMsg:
|
||||||
|
debugdate += QString(" [Fatal] %1: %2 (%3:%4, %5)").arg(context.category).arg(msg).arg(context.file)
|
||||||
|
.arg(context.line).arg(context.function);
|
||||||
|
messageBox.setIcon(QMessageBox::Critical);
|
||||||
|
messageBox.setInformativeText(msg);
|
||||||
|
messageBox.setStandardButtons(QMessageBox::Ok);
|
||||||
|
messageBox.exec();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*qApp->LogFile()) << debugdate << endl;
|
||||||
|
|
||||||
|
if (QtFatalMsg == type)
|
||||||
|
{
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (type != QtDebugMsg)
|
||||||
|
{
|
||||||
|
abort(); // be NOISY unless overridden!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
const qreal VApplication::PrintDPI = 96.0;
|
const qreal VApplication::PrintDPI = 96.0;
|
||||||
|
|
||||||
|
@ -64,8 +155,8 @@ VApplication::VApplication(int &argc, char **argv)
|
||||||
guiTexts(QMap<QString, VTranslation>()), descriptions(QMap<QString, VTranslation>()),
|
guiTexts(QMap<QString, VTranslation>()), descriptions(QMap<QString, VTranslation>()),
|
||||||
variables(QMap<QString, VTranslation>()), functions(QMap<QString, VTranslation>()),
|
variables(QMap<QString, VTranslation>()), functions(QMap<QString, VTranslation>()),
|
||||||
postfixOperators(QMap<QString, VTranslation>()), stDescriptions(QMap<QString, VTranslation>()),
|
postfixOperators(QMap<QString, VTranslation>()), stDescriptions(QMap<QString, VTranslation>()),
|
||||||
undoStack(nullptr), sceneView(nullptr), currentScene(nullptr),
|
undoStack(nullptr), sceneView(nullptr), currentScene(nullptr), autoSaveTimer(nullptr), mainWindow(nullptr),
|
||||||
autoSaveTimer(nullptr), mainWindow(nullptr), openingPattern(false), settings(nullptr), doc(nullptr)
|
openingPattern(false), settings(nullptr), doc(nullptr), log(nullptr), out(nullptr)
|
||||||
{
|
{
|
||||||
undoStack = new QUndoStack(this);
|
undoStack = new QUndoStack(this);
|
||||||
|
|
||||||
|
@ -77,6 +168,19 @@ VApplication::VApplication(int &argc, char **argv)
|
||||||
InitSTDescriptions();
|
InitSTDescriptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VApplication::~VApplication()
|
||||||
|
{
|
||||||
|
qInstallMessageHandler(0); // Resore the message handler
|
||||||
|
delete out;
|
||||||
|
|
||||||
|
if (log != nullptr)
|
||||||
|
{
|
||||||
|
log->close();
|
||||||
|
delete log;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief NewValentina start Valentina in new process, send path to pattern file in argument.
|
* @brief NewValentina start Valentina in new process, send path to pattern file in argument.
|
||||||
|
@ -295,6 +399,25 @@ void VApplication::InitMeasurement(const QString &name, const VTranslation &m, c
|
||||||
descriptions.insert(name, d);
|
descriptions.insert(name, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VApplication::LogDirPath() const
|
||||||
|
{
|
||||||
|
#if defined(Q_OS_WIN) || defined(Q_OS_OSX)
|
||||||
|
const QString logDirPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QString(),
|
||||||
|
QStandardPaths::LocateDirectory) + "Valentina";
|
||||||
|
#else
|
||||||
|
const QString logDirPath = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString(),
|
||||||
|
QStandardPaths::LocateDirectory) + organizationName();
|
||||||
|
#endif
|
||||||
|
return logDirPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VApplication::LogPath() const
|
||||||
|
{
|
||||||
|
return LogDirPath() + "/valentina.log";
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VApplication::InitMeasurements()
|
void VApplication::InitMeasurements()
|
||||||
{
|
{
|
||||||
|
@ -1854,6 +1977,34 @@ bool VApplication::SafeCopy(const QString &source, const QString &destination, Q
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VApplication::StartLogging()
|
||||||
|
{
|
||||||
|
QDir logDir(LogDirPath());
|
||||||
|
if (logDir.exists() == false)
|
||||||
|
{
|
||||||
|
logDir.mkpath("."); // Create directory for log if need
|
||||||
|
}
|
||||||
|
|
||||||
|
log = new QFile(LogPath());
|
||||||
|
if (log->open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
|
||||||
|
{
|
||||||
|
out = new QTextStream(log);
|
||||||
|
qInstallMessageHandler(noisyFailureMsgHandler);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete log;
|
||||||
|
qDebug() << "Error opening log file '" << LogPath() << "'. All debug output redirected to console.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QTextStream *VApplication::LogFile()
|
||||||
|
{
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
// Catch exception and create report. Use if program build with Mingw compiler.
|
// Catch exception and create report. Use if program build with Mingw compiler.
|
||||||
|
@ -1905,12 +2056,16 @@ void VApplication::CollectReport(const QString &reportName) const
|
||||||
}
|
}
|
||||||
|
|
||||||
const QDateTime now = QDateTime::currentDateTime();
|
const QDateTime now = QDateTime::currentDateTime();
|
||||||
const QString timestamp = now.toString(QLatin1String("yyyyMMdd-hhmmsszzz"));
|
const QString timestamp = now.toString(QLatin1String("yyyy.MM.dd-hh_mm_ss"));
|
||||||
const QString filename = QString("%1/reports/crash-%2.RPT").arg(qApp->applicationDirPath()).arg(timestamp);
|
QString filename = QString("%1/reports/crash-%2.RPT").arg(qApp->applicationDirPath()).arg(timestamp);
|
||||||
|
|
||||||
QFile reportFile(reportName);
|
QFile reportFile(reportName);
|
||||||
reportFile.copy(filename); // Collect new crash
|
reportFile.copy(filename); // Collect new crash
|
||||||
reportFile.remove(); // Clear after yourself
|
reportFile.remove(); // Clear after yourself
|
||||||
|
|
||||||
|
filename = QString("%1/reports/log-%2.log").arg(qApp->applicationDirPath()).arg(timestamp);
|
||||||
|
QFile logFile(LogPath());
|
||||||
|
logFile.copy(filename); // Collect log
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -1928,23 +2083,22 @@ void VApplication::SendReport(const QString &reportName) const
|
||||||
{
|
{
|
||||||
QString content;
|
QString content;
|
||||||
QFile reportFile(reportName);
|
QFile reportFile(reportName);
|
||||||
if (!reportFile.open(QIODevice::ReadOnly | QIODevice::Text))
|
if (reportFile.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
{
|
{
|
||||||
return;
|
content = ReadFileForSending(reportFile);
|
||||||
}
|
|
||||||
|
|
||||||
QTextStream in(&reportFile);
|
|
||||||
while (!in.atEnd())
|
|
||||||
{
|
|
||||||
content.append(in.readLine()+"\r\n");// Windows end of line
|
|
||||||
}
|
|
||||||
reportFile.close();
|
reportFile.close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
content = reportFile.errorString() + "\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
// Additional information
|
// Additional information
|
||||||
content.append(QString("-------------------------------")+"\r\n");
|
content.append(QString("-------------------------------")+"\r\n");
|
||||||
content.append(QString("Version:%1").arg(APP_VERSION)+"\r\n");
|
content.append(QString("Version:%1").arg(APP_VERSION)+"\r\n");
|
||||||
content.append(QString("Based on Qt %2 (32 bit)").arg(QT_VERSION_STR)+"\r\n");
|
content.append(QString("Based on Qt %2 (32 bit)").arg(QT_VERSION_STR)+"\r\n");
|
||||||
content.append(QString("Built on %3 at %4").arg(__DATE__).arg(__TIME__)+"\r\n");
|
content.append(QString("Built on %3 at %4").arg(__DATE__).arg(__TIME__)+"\r\n");
|
||||||
|
content.append("\r\n");
|
||||||
|
|
||||||
// Creating json with report
|
// Creating json with report
|
||||||
// Example:
|
// Example:
|
||||||
|
@ -1952,7 +2106,7 @@ void VApplication::SendReport(const QString &reportName) const
|
||||||
// "description":"Crash report",
|
// "description":"Crash report",
|
||||||
// "public":"true",
|
// "public":"true",
|
||||||
// "files":{
|
// "files":{
|
||||||
// "file1.txt":{
|
// "valentina.RPT":{
|
||||||
// "content":"Report text here"
|
// "content":"Report text here"
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
@ -1967,12 +2121,29 @@ void VApplication::SendReport(const QString &reportName) const
|
||||||
reportObject.insert(QStringLiteral("description"), QJsonValue(report));
|
reportObject.insert(QStringLiteral("description"), QJsonValue(report));
|
||||||
reportObject.insert(QStringLiteral("public"), QJsonValue(QString("true")));
|
reportObject.insert(QStringLiteral("public"), QJsonValue(QString("true")));
|
||||||
|
|
||||||
QJsonObject contentObject;
|
content.append("\r\n");
|
||||||
contentObject.insert(QStringLiteral("content"), QJsonValue(content));
|
content.append(QString("-------------------------------")+"\r\n");
|
||||||
|
content.append(QString("Log:")+"\r\n");
|
||||||
|
|
||||||
|
QFile logFile(LogPath());
|
||||||
|
if (logFile.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
|
{
|
||||||
|
content.append(ReadFileForSending(logFile));
|
||||||
|
logFile.close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
content = logFile.errorString() + "\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString contentSection = QStringLiteral("content");
|
||||||
|
QJsonObject contentObject;
|
||||||
|
contentObject.insert(contentSection, QJsonValue(content));
|
||||||
|
|
||||||
|
const QString filesSection = QStringLiteral("files");
|
||||||
QJsonObject fileObject;
|
QJsonObject fileObject;
|
||||||
fileObject.insert(QFileInfo(reportName).fileName(), QJsonValue(contentObject));
|
fileObject.insert(QFileInfo(reportName).fileName(), QJsonValue(contentObject));
|
||||||
reportObject.insert(QStringLiteral("files"), QJsonValue(fileObject));
|
reportObject.insert(filesSection, QJsonValue(fileObject));
|
||||||
|
|
||||||
QFile gistFile(GistFileName);
|
QFile gistFile(GistFileName);
|
||||||
if (!gistFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
|
if (!gistFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
|
||||||
|
@ -2001,4 +2172,16 @@ void VApplication::SendReport(const QString &reportName) const
|
||||||
CollectReport(reportName);
|
CollectReport(reportName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VApplication::ReadFileForSending(QFile &file) const
|
||||||
|
{
|
||||||
|
QString content;
|
||||||
|
QTextStream in(&file);
|
||||||
|
while (!in.atEnd())
|
||||||
|
{
|
||||||
|
content.append(in.readLine()+"\r\n");// Windows end of line
|
||||||
|
}
|
||||||
|
return content;
|
||||||
|
}
|
||||||
#endif //defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
#endif //defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
||||||
|
|
|
@ -40,6 +40,7 @@ class QUndoStack;
|
||||||
class VMainGraphicsView;
|
class VMainGraphicsView;
|
||||||
class VMainGraphicsScene;
|
class VMainGraphicsScene;
|
||||||
class VPattern;
|
class VPattern;
|
||||||
|
class QFile;
|
||||||
|
|
||||||
#if defined(qApp)
|
#if defined(qApp)
|
||||||
#undef qApp
|
#undef qApp
|
||||||
|
@ -54,7 +55,7 @@ class VApplication : public QApplication
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VApplication(int &argc, char ** argv);
|
VApplication(int &argc, char ** argv);
|
||||||
virtual ~VApplication() {}
|
virtual ~VApplication();
|
||||||
static void NewValentina(const QString &fileName = QString());
|
static void NewValentina(const QString &fileName = QString());
|
||||||
static void CheckFactor(qreal &oldFactor, const qreal &Newfactor);
|
static void CheckFactor(qreal &oldFactor, const qreal &Newfactor);
|
||||||
virtual bool notify(QObject * receiver, QEvent * event);
|
virtual bool notify(QObject * receiver, QEvent * event);
|
||||||
|
@ -103,13 +104,19 @@ public:
|
||||||
static QStringList LabelLanguages();
|
static QStringList LabelLanguages();
|
||||||
QString STDescription(const QString &id)const;
|
QString STDescription(const QString &id)const;
|
||||||
static bool SafeCopy(const QString &source, const QString &destination, QString &error);
|
static bool SafeCopy(const QString &source, const QString &destination, QString &error);
|
||||||
|
void StartLogging();
|
||||||
|
QTextStream *LogFile();
|
||||||
|
|
||||||
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
||||||
static void DrMingw();
|
static void DrMingw();
|
||||||
void CollectReports() const;
|
void CollectReports() const;
|
||||||
|
#endif // defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
||||||
void CleanGist() const;
|
void CleanGist() const;
|
||||||
#endif // defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
#endif // defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VApplication)
|
Q_DISABLE_COPY(VApplication)
|
||||||
Unit _patternUnit;
|
Unit _patternUnit;
|
||||||
|
@ -143,6 +150,8 @@ private:
|
||||||
QSettings *settings;
|
QSettings *settings;
|
||||||
|
|
||||||
VPattern *doc;
|
VPattern *doc;
|
||||||
|
QFile *log;
|
||||||
|
QTextStream *out;
|
||||||
void InitLineWidth();
|
void InitLineWidth();
|
||||||
void InitMeasurements();
|
void InitMeasurements();
|
||||||
void InitVariables();
|
void InitVariables();
|
||||||
|
@ -166,7 +175,11 @@ private:
|
||||||
|
|
||||||
void CollectReport(const QString &reportName) const;
|
void CollectReport(const QString &reportName) const;
|
||||||
void SendReport(const QString &reportName) const;
|
void SendReport(const QString &reportName) const;
|
||||||
|
QString ReadFileForSending(QFile &file)const;
|
||||||
#endif // defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
#endif // defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
||||||
|
|
||||||
|
QString LogDirPath()const;
|
||||||
|
QString LogPath()const;
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -43,85 +43,6 @@
|
||||||
#include "tablewindow.h"
|
#include "tablewindow.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
|
||||||
{
|
|
||||||
// Why on earth didn't Qt want to make failed signal/slot connections qWarning?
|
|
||||||
if ((type == QtDebugMsg) && msg.contains("::connect"))
|
|
||||||
{
|
|
||||||
type = QtWarningMsg;
|
|
||||||
}
|
|
||||||
|
|
||||||
// this is another one that doesn't make sense as just a debug message. pretty serious
|
|
||||||
// sign of a problem
|
|
||||||
// http://www.developer.nokia.com/Community/Wiki/QPainter::begin:Paint_device_returned_engine_%3D%3D_0_(Known_Issue)
|
|
||||||
if ((type == QtDebugMsg) && msg.contains("QPainter::begin") && msg.contains("Paint device returned engine"))
|
|
||||||
{
|
|
||||||
type = QtWarningMsg;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This qWarning about "Cowardly refusing to send clipboard message to hung application..."
|
|
||||||
// is something that can easily happen if you are debugging and the application is paused.
|
|
||||||
// As it is so common, not worth popping up a dialog.
|
|
||||||
if ((type == QtWarningMsg) && QString(msg).contains("QClipboard::event")
|
|
||||||
&& QString(msg).contains("Cowardly refusing"))
|
|
||||||
{
|
|
||||||
type = QtDebugMsg;
|
|
||||||
}
|
|
||||||
|
|
||||||
// only the GUI thread should display message boxes. If you are
|
|
||||||
// writing a multithreaded application and the error happens on
|
|
||||||
// a non-GUI thread, you'll have to queue the message to the GUI
|
|
||||||
QCoreApplication *instance = QCoreApplication::instance();
|
|
||||||
const bool isGuiThread = instance && (QThread::currentThread() == instance->thread());
|
|
||||||
|
|
||||||
if (isGuiThread)
|
|
||||||
{
|
|
||||||
QByteArray localMsg = msg.toLocal8Bit();
|
|
||||||
QMessageBox messageBox;
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case QtDebugMsg:
|
|
||||||
fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
|
|
||||||
context.function);
|
|
||||||
return;
|
|
||||||
case QtWarningMsg:
|
|
||||||
messageBox.setIcon(QMessageBox::Warning);
|
|
||||||
messageBox.setInformativeText(msg);
|
|
||||||
messageBox.setStandardButtons(QMessageBox::Ok);
|
|
||||||
fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
|
|
||||||
context.function);
|
|
||||||
messageBox.exec();
|
|
||||||
break;
|
|
||||||
case QtCriticalMsg:
|
|
||||||
messageBox.setIcon(QMessageBox::Critical);
|
|
||||||
messageBox.setInformativeText(msg);
|
|
||||||
messageBox.setStandardButtons(QMessageBox::Ok);
|
|
||||||
fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
|
|
||||||
context.function);
|
|
||||||
messageBox.exec();
|
|
||||||
abort();
|
|
||||||
case QtFatalMsg:
|
|
||||||
messageBox.setIcon(QMessageBox::Critical);
|
|
||||||
messageBox.setInformativeText(msg);
|
|
||||||
messageBox.setStandardButtons(QMessageBox::Ok);
|
|
||||||
fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
|
|
||||||
context.function);
|
|
||||||
messageBox.exec();
|
|
||||||
abort();
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (type != QtDebugMsg)
|
|
||||||
{
|
|
||||||
abort(); // be NOISY unless overridden!
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -134,14 +55,6 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
VApplication app(argc, argv);
|
VApplication app(argc, argv);
|
||||||
|
|
||||||
#ifdef QT_DEBUG
|
|
||||||
// Because our "noisy" message handler uses the GUI subsystem for message
|
|
||||||
// boxes, we can't install it until after the QApplication is constructed. But it
|
|
||||||
// is good to be the very next thing to run, to start catching warnings ASAP.
|
|
||||||
{
|
|
||||||
qInstallMessageHandler(noisyFailureMsgHandler);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
app.setApplicationDisplayName(VER_PRODUCTNAME_STR);
|
app.setApplicationDisplayName(VER_PRODUCTNAME_STR);
|
||||||
app.setApplicationName(VER_INTERNALNAME_STR);
|
app.setApplicationName(VER_INTERNALNAME_STR);
|
||||||
app.setOrganizationName(VER_COMPANYNAME_STR);
|
app.setOrganizationName(VER_COMPANYNAME_STR);
|
||||||
|
@ -152,10 +65,14 @@ int main(int argc, char *argv[])
|
||||||
app.OpenSettings();
|
app.OpenSettings();
|
||||||
|
|
||||||
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
||||||
|
// Catch and send report
|
||||||
VApplication::DrMingw();
|
VApplication::DrMingw();
|
||||||
app.CollectReports();
|
app.CollectReports();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Run creation log after sending crash report
|
||||||
|
app.StartLogging();
|
||||||
|
|
||||||
QString checkedLocale = qApp->getSettings()->value("configuration/locale", QLocale::system().name()).toString();
|
QString checkedLocale = qApp->getSettings()->value("configuration/locale", QLocale::system().name()).toString();
|
||||||
|
|
||||||
QTranslator qtTranslator;
|
QTranslator qtTranslator;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user