|
@@ -3,18 +3,60 @@
|
|
|
#include <QFontDatabase>
|
|
#include <QFontDatabase>
|
|
|
#include <QDebug>
|
|
#include <QDebug>
|
|
|
#include <QDialog>
|
|
#include <QDialog>
|
|
|
-
|
|
|
|
|
|
|
+#include <QDateTime>
|
|
|
|
|
|
|
|
#include "widget.h"
|
|
#include "widget.h"
|
|
|
#include "spdlog/spdlog.h"
|
|
#include "spdlog/spdlog.h"
|
|
|
|
|
|
|
|
|
|
+#ifdef Q_OS_WIN
|
|
|
|
|
+#include <windows.h>
|
|
|
|
|
+#include <dbghelp.h>
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
void addFont();
|
|
void addFont();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+#ifdef Q_OS_WIN
|
|
|
|
|
+// 异常处理函数
|
|
|
|
|
+LONG __stdcall ApplicationCrashHandler(EXCEPTION_POINTERS *pException)
|
|
|
|
|
+{
|
|
|
|
|
+ // 生成带时间戳的Dump文件名
|
|
|
|
|
+ QString dumpFileName = QString("crash_%1.dmp")
|
|
|
|
|
+ .arg(QDateTime::currentDateTime().toString(QStringLiteral("yyyyMMdd_hhmmss")));
|
|
|
|
|
+ // QString dumpFileName = QString("crash_%1.dmp").arg(QDateTime::currentDateTime().toString("yyyyMMdd_hhmmss"));
|
|
|
|
|
+
|
|
|
|
|
+ HANDLE hDumpFile = CreateFileW( (LPCWSTR)dumpFileName.utf16(), GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
|
|
|
|
+ if (hDumpFile != INVALID_HANDLE_VALUE) {
|
|
|
|
|
+ // 定义Dump信息
|
|
|
|
|
+ MINIDUMP_EXCEPTION_INFORMATION dumpInfo;
|
|
|
|
|
+ dumpInfo.ExceptionPointers = pException;
|
|
|
|
|
+ dumpInfo.ThreadId = GetCurrentThreadId();
|
|
|
|
|
+ dumpInfo.ClientPointers = TRUE;
|
|
|
|
|
+
|
|
|
|
|
+ // 写入Dump文件
|
|
|
|
|
+ MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hDumpFile, MiniDumpNormal, &dumpInfo, nullptr, nullptr);
|
|
|
|
|
+ CloseHandle(hDumpFile);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 这里可以添加错误提示、保存日志等操作
|
|
|
|
|
+ // ...
|
|
|
|
|
+
|
|
|
|
|
+ return EXCEPTION_EXECUTE_HANDLER;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
int main(int argc, char *argv[])
|
|
int main(int argc, char *argv[])
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
QApplication app(argc, argv);
|
|
QApplication app(argc, argv);
|
|
|
|
|
+#ifdef Q_OS_WIN
|
|
|
|
|
+ SetUnhandledExceptionFilter(ApplicationCrashHandler);
|
|
|
|
|
+#endif
|
|
|
addFont();
|
|
addFont();
|
|
|
|
|
|
|
|
/* 设置日志输出等级 */
|
|
/* 设置日志输出等级 */
|