diff --git a/.gitignore b/.gitignore index 53d8770..bea2ad5 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,5 @@ build cmake-* .idea .vs -.cache \ No newline at end of file +.cache +xpbuild \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 496b033..26afbc4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -24,16 +24,12 @@ "-Wno-dev" ], "cmake.environment": { - "QT_LIB_ROOT": "C:/Qt/Qt5.6.3/5.6.3/mingw49_32", - "PATH": "${env:PATH};C:/Qt/Qt5.6.3/5.6.3/mingw49_32/bin" + "QT_LIB_ROOT": "D:/Dev/Qt6/msvc2022_64", + "PATH": "${env:PATH};D:/Dev/Qt6/msvc2022_64/bin" }, - // "cmake.environment": { - // "QT_LIB_ROOT": "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64", - // "PATH": "${env:PATH};C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/bin" - // }, "cmake.configureSettings": { "CMAKE_PREFIX_PATH": "${env:QT_LIB_ROOT}", - "XP_PLATFORM_SUPPORT": "ON" + "QT_DEFAULT_MAJOR_VERSION": "6", }, "cmake.options.statusBarVisibility": "visible", "cmake.generator": "Ninja", diff --git a/CMakeLists.txt b/CMakeLists.txt index 81c3ae7..8a93f00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,11 @@ set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(PROJECT_URL "https://github.com/taynpg/frelay") -set(QT_DEFAULT_MAJOR_VERSION 5) + +if(NOT DEFINED QT_DEFAULT_MAJOR_VERSION) +set(QT_DEFAULT_MAJOR_VERSION 6) +endif() + set(QAPPLICATION_CLASS QApplication) if (MSVC) @@ -20,7 +24,8 @@ endif() if(WIN32) if(DEFINED XP_PLATFORM_SUPPORT) -message(STATUS "Support Windows XP platform.") +message(STATUS "Support Windows XP platform => ${XP_PLATFORM_SUPPORT}.") +include_directories(${CMAKE_SOURCE_DIR}/Gui/Control) add_definitions(-D_WIN32_WINNT=0x0501) else() add_definitions(-D_WIN32_WINNT=0x0601) diff --git a/ClientCore/ClientCore.cpp b/ClientCore/ClientCore.cpp index e364c1a..7448ef3 100644 --- a/ClientCore/ClientCore.cpp +++ b/ClientCore/ClientCore.cpp @@ -36,6 +36,10 @@ void ClientCore::DoConnect(const QString& ip, quint16 port) bool ClientCore::Connect(const QString& ip, quint16 port) { + if (connected_) { + qInfo() << QString(tr("already connected.")); + return true; + } socket_->connectToHost(ip, port); if (!socket_->waitForConnected(3000)) { qCritical() << QString(tr("%1:%2 connect failed...")).arg(ip).arg(port); diff --git a/ClientCore/ClientCore.h b/ClientCore/ClientCore.h index 6e6d72e..811a428 100644 --- a/ClientCore/ClientCore.h +++ b/ClientCore/ClientCore.h @@ -26,12 +26,14 @@ public: public slots: bool SendFrame(QSharedPointer frame); + void Disconnect(); + +public slots: + void DoConnect(const QString& ip, quint16 port); public: void Instance(); bool Connect(const QString& ip, quint16 port); - void DoConnect(const QString& ip, quint16 port); - void Disconnect(); bool Send(QSharedPointer frame); bool Send(const char* data, qint64 len); bool IsConnect(); diff --git a/Gui/Control/ConnectControl.cpp b/Gui/Control/ConnectControl.cpp index 64f334d..b06af9c 100644 --- a/Gui/Control/ConnectControl.cpp +++ b/Gui/Control/ConnectControl.cpp @@ -48,7 +48,8 @@ void Connecter::RunWorker(ClientCore* clientCore) }); connect(this, &Connecter::sigDoConnect, clientCore_, &ClientCore::DoConnect); - connect(this, &Connecter::sigDisConnect, clientCore_, &ClientCore::Disconnect); + connect(this, &Connecter::sigDisConnect, this, + [this]() { QMetaObject::invokeMethod(clientCore_, "Disconnect", Qt::QueuedConnection); }); connect(sockWorker_, &QThread::finished, sockWorker_, &QObject::deleteLater); heatBeat_->start(); diff --git a/Script/xpbuild.bat b/Script/xpbuild.bat new file mode 100644 index 0000000..d992d45 --- /dev/null +++ b/Script/xpbuild.bat @@ -0,0 +1,37 @@ +@echo on + +set QT_563_ROOT=C:\Qt\Qt5.6.3 +set QT_DIRS="%QT_563_ROOT%\5.6.3\mingw49_32" +set QT_GCC_ROOT="%QT_563_ROOT%\Tools\mingw49_32\bin" + +set MINGWDLL1="%QT_563_ROOT%\Tools\mingw492_32\bin\libgcc_s_dw2-1.dll" +set MINGWDLL2="%QT_563_ROOT%\Tools\mingw492_32\bin\libstdc++-6.dll" +set MINGWDLL3="%QT_563_ROOT%\Tools\mingw492_32\bin\libwinpthread-1.dll" +set QTDLL1="%QT_563_ROOT%\5.6.3\mingw49_32\bin\Qt5Core.dll" +set QTDLL2="%QT_563_ROOT%\5.6.3\mingw49_32\bin\Qt5Gui.dll" +set QTDLL3="%QT_563_ROOT%\5.6.3\mingw49_32\bin\Qt5Widgets.dll" +set QTDLL4="%QT_563_ROOT%\5.6.3\mingw49_32\bin\Qt5Network.dll" +set QTDLL5="%QT_563_ROOT%\5.6.3\mingw49_32\plugins\platforms\qwindows.dll" + +set PAHT=%PATH%;%QT_GCC_ROOT%; + +cmake -B"%~dp0..\xpbuild" -S"%~dp0.." -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=%QT_DIRS% -DQT_DEFAULT_MAJOR_VERSION=5 -DXP_PLATFORM_SUPPORT=ON +cmake --build "%~dp0..\xpbuild" --config Release + +if %errorlevel% equ 0 ( + if not exist "%~dp0..\xpbuild\bin\Release\platforms" ( + mkdir "%~dp0..\xpbuild\bin\Release\platforms" + ) + xcopy /Y %MINGWDLL1% "%~dp0..\xpbuild\bin\Release" + xcopy /Y %MINGWDLL2% "%~dp0..\xpbuild\bin\Release" + xcopy /Y %MINGWDLL3% "%~dp0..\xpbuild\bin\Release" + xcopy /Y %QTDLL1% "%~dp0..\xpbuild\bin\Release" + xcopy /Y %QTDLL2% "%~dp0..\xpbuild\bin\Release" + xcopy /Y %QTDLL3% "%~dp0..\xpbuild\bin\Release" + xcopy /Y %QTDLL4% "%~dp0..\xpbuild\bin\Release" + xcopy /Y %QTDLL5% "%~dp0..\xpbuild\bin\Release\platforms" + del /f /q "%~dp0..\xpbuild\bin\Release\frelayBaseTest.exe" + del /f /q "%~dp0..\xpbuild\bin\Release\frelayTest.exe" +) + +pause \ No newline at end of file diff --git a/crashelper/src/crashelper.cxx b/crashelper/src/crashelper.cxx index c733f2f..cb3f04b 100644 --- a/crashelper/src/crashelper.cxx +++ b/crashelper/src/crashelper.cxx @@ -132,7 +132,7 @@ void UseExceptionHandler(EXCEPTION_POINTERS* exception) QString fullPath = QDir(h.dumpSavePath_).absoluteFilePath(dumpName); QString fullFailedPath = QDir(h.dumpSavePath_).absoluteFilePath(dumpFailedLog); - HANDLE hFile = CreateFile(fullPath.toStdString().c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFileA(fullPath.toStdString().c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { QFile file(fullFailedPath); if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {