Browse Source

Link Winsock after uasync and include socket headers first

master
evgeny 5 days ago
parent
commit
c81e8e5025
  1. 7
      tools/chatgui/libutun/CMakeLists.txt
  2. 10
      tools/chatgui/src/main.cpp

7
tools/chatgui/libutun/CMakeLists.txt

@ -66,6 +66,11 @@ set_target_properties(opus_internal PROPERTIES
target_link_libraries(uasync PUBLIC opus_internal)
# WinSock вызывается в uasync (DNS/сокеты/event loop); импортная библиотека нужна после её архива.
if(WIN32)
target_link_libraries(uasync PUBLIC ws2_32)
endif()
target_compile_definitions(uasync PRIVATE
_ISOC99_SOURCE
DEBUG_OUTPUT_STDERR
@ -156,5 +161,5 @@ target_link_libraries(utun PUBLIC
# Platform-specific link flags
if(WIN32)
target_link_libraries(utun PUBLIC ws2_32 iphlpapi advapi32 bcrypt dbghelp)
target_link_libraries(utun PUBLIC iphlpapi advapi32 bcrypt dbghelp)
endif()

10
tools/chatgui/src/main.cpp

@ -1,3 +1,6 @@
#ifdef _WIN32
#include <winsock2.h>
#endif
#include <QCoreApplication>
#include <QApplication>
#include <QIcon>
@ -39,9 +42,10 @@ static DWORD count_threads(void) {
static BOOL WINAPI console_ctrl_handler(DWORD dwCtrlType) {
if (dwCtrlType == CTRL_C_EVENT || dwCtrlType == CTRL_BREAK_EVENT) {
if (g_mainWindow)
QMetaObject::invokeMethod(g_mainWindow, [g_mainWindow] {
g_mainWindow->requestShutdown();
MainWindow* window = g_mainWindow;
if (window)
QMetaObject::invokeMethod(window, [window] {
window->requestShutdown();
}, Qt::QueuedConnection);
else if (g_ctrl_node)
g_ctrl_node->requestStop();

Loading…
Cancel
Save