2022-05-03 10:25:52 +00:00
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
|
#include <QTranslator>
|
|
|
|
|
#include <QScreen>
|
2022-07-02 07:59:09 +00:00
|
|
|
|
#include "base/HGDef.h"
|
|
|
|
|
#include "base/HGInc.h"
|
|
|
|
|
#include "base/HGUtility.h"
|
|
|
|
|
#include "HGVersion.h"
|
|
|
|
|
#include "curl/curl.h"
|
|
|
|
|
#if defined(HG_CMP_MSC)
|
|
|
|
|
#include <Dbghelp.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-07-07 02:49:05 +00:00
|
|
|
|
ServerConfig g_serverCfg;
|
|
|
|
|
|
2022-07-02 07:59:09 +00:00
|
|
|
|
#if defined(HG_CMP_MSC)
|
|
|
|
|
static LONG WINAPI UnhandledExceptionFilterEx(struct _EXCEPTION_POINTERS *ExceptionInfo)
|
|
|
|
|
{
|
|
|
|
|
HGChar tmpPath[256];
|
|
|
|
|
HGBase_GetTmpFileName("dmp", tmpPath, 256);
|
|
|
|
|
|
|
|
|
|
HANDLE hFile = CreateFileA(tmpPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
|
if (INVALID_HANDLE_VALUE == hFile)
|
|
|
|
|
{
|
|
|
|
|
return EXCEPTION_EXECUTE_HANDLER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MINIDUMP_EXCEPTION_INFORMATION mdei;
|
|
|
|
|
mdei.ThreadId = GetCurrentThreadId();
|
|
|
|
|
mdei.ExceptionPointers = ExceptionInfo;
|
|
|
|
|
mdei.ClientPointers = TRUE;
|
|
|
|
|
MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &mdei, NULL, NULL);
|
|
|
|
|
CloseHandle(hFile);
|
|
|
|
|
|
|
|
|
|
char exceptionAddr[32] = {0};
|
|
|
|
|
#ifdef _WIN64
|
|
|
|
|
sprintf(exceptionAddr, "0x%016p", ExceptionInfo->ExceptionRecord->ExceptionAddress);
|
|
|
|
|
#else
|
|
|
|
|
sprintf(exceptionAddr, "0x%08p", ExceptionInfo->ExceptionRecord->ExceptionAddress);
|
|
|
|
|
#endif
|
|
|
|
|
// 上传
|
|
|
|
|
PostCrashInfo(tmpPath, exceptionAddr);
|
|
|
|
|
HGBase_DeleteFile(tmpPath);
|
|
|
|
|
|
|
|
|
|
return EXCEPTION_EXECUTE_HANDLER;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2022-05-03 10:25:52 +00:00
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
QApplication a(argc, argv);
|
|
|
|
|
|
2022-07-02 07:59:09 +00:00
|
|
|
|
curl_global_init(CURL_GLOBAL_ALL);
|
|
|
|
|
|
2022-07-07 02:49:05 +00:00
|
|
|
|
GetServerConfig(g_serverCfg);
|
|
|
|
|
|
|
|
|
|
if (g_serverCfg.postCrashInfo)
|
|
|
|
|
{
|
2022-07-02 07:59:09 +00:00
|
|
|
|
#if defined(HG_CMP_MSC)
|
2022-07-07 02:49:05 +00:00
|
|
|
|
SetUnhandledExceptionFilter(UnhandledExceptionFilterEx);
|
2022-07-02 07:59:09 +00:00
|
|
|
|
#endif
|
2022-07-07 02:49:05 +00:00
|
|
|
|
}
|
2022-07-02 07:59:09 +00:00
|
|
|
|
|
2022-05-03 10:25:52 +00:00
|
|
|
|
QTranslator translator_qt_;
|
|
|
|
|
if (translator_qt_.load(":translation/qt_zh_CN.qm"))
|
|
|
|
|
a.installTranslator(&translator_qt_);
|
|
|
|
|
|
|
|
|
|
QTranslator translator_qt;
|
|
|
|
|
if (translator_qt.load(":translation/Scanner_zh_CN.qm"))
|
|
|
|
|
a.installTranslator(&translator_qt);
|
|
|
|
|
|
|
|
|
|
MainWindow w;
|
|
|
|
|
QScreen *screen = QGuiApplication::primaryScreen();
|
|
|
|
|
w.move((screen->size().width() - w.width()) / 2, (screen->size().height() - w.height()) / 2);
|
|
|
|
|
w.show();
|
2022-07-02 07:59:09 +00:00
|
|
|
|
a.exec();
|
|
|
|
|
|
|
|
|
|
curl_global_cleanup();
|
|
|
|
|
return 0;
|
2022-05-03 10:25:52 +00:00
|
|
|
|
}
|