From 7338ef8766c10ff1aa8b07b5fb41582b4ca517cf Mon Sep 17 00:00:00 2001 From: "Alexandru Vlad (Scai)" <59282365+alexevladgabriel@users.noreply.github.com> Date: Sun, 22 Nov 2026 10:15:28 +0200 Subject: [PATCH 1/2] fix: query server info on a bounded thread pool v1.1.1 started one QThread per server for every info query. Each thread needs an event-dispatcher pipe, so with ~110 servers the app exceeded macOS's 256 open-file limit for GUI apps and Qt aborted in QEventDispatcherUNIXPrivate a few seconds after launch. Info queries now run on a QThreadPool capped at 8 threads and report back to the main thread with a queued call; the reply is owned by a shared_ptr instead of being deleted in ServerInfoReady. Also: generate the version header as generated_version.h so the build uses the CMake project version, and only compare commit hashes in the update checker when both sides are real 40-character SHAs. --- CMakeLists.txt | 4 +++- mainwindow.cpp | 18 ++++++++++++++++-- mainwindow.h | 5 ++++- query.cpp | 12 ------------ query.h | 15 --------------- query_slots.cpp | 12 ++---------- serverinfo.cpp | 3 +-- updatechecker.cpp | 8 +++++--- version.h | 10 +++++++--- version.h.in | 6 +++--- worker.cpp | 7 ------- worker.h | 2 -- 12 files changed, 41 insertions(+), 61 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eba1779..ed183de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ endif() # Generate version header from project version configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/version.h.in" - "${CMAKE_CURRENT_BINARY_DIR}/version.h" + "${CMAKE_CURRENT_BINARY_DIR}/generated_version.h" @ONLY ) @@ -94,6 +94,8 @@ qt_add_executable(${PROJECT_NAME} ${RESOURCES} ) +target_compile_definitions(${PROJECT_NAME} PRIVATE SOURCEADMINTOOL_GENERATED_VERSION) + # Find third-party libraries # On macOS, always use bundled static libs to avoid Homebrew dynamic lib crashes if(APPLE) diff --git a/mainwindow.cpp b/mainwindow.cpp index 2e93c62..5e7c969 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -11,6 +11,7 @@ #include #include #include +#include extern Settings *settings; extern QList serverList; @@ -63,6 +64,8 @@ MainWindow::MainWindow(QWidget *parent) : m_updateChecker = new UpdateChecker(this); Database::instance()->open(); + infoQueryPool.setMaxThreadCount(8); + settings = new Settings(this); settings->SetDefaultSettings(); settings->ReadSettings(); @@ -101,6 +104,7 @@ MainWindow::MainWindow(QWidget *parent) : MainWindow::~MainWindow() { + infoQueryPool.waitForDone(); Database::instance()->close(); delete settings; serverList.clear(); @@ -110,6 +114,17 @@ MainWindow::~MainWindow() delete commandIter; } +void MainWindow::QueueInfoQuery(QHostAddress host, quint16 port, ServerTableIndexItem *item) +{ + item->GetServerInfo()->queryState = QueryRunning; + infoQueryPool.start([this, host, port, item]() { + std::shared_ptr reply(GetInfoReply(host, port)); + QMetaObject::invokeMethod(this, [this, reply, item]() { + ServerInfoReady(reply.get(), item); + }, Qt::QueuedConnection); + }); +} + AddServerError MainWindow::CheckServerList(QString server) { QStringList address = server.split(":"); @@ -192,8 +207,7 @@ ServerInfo *MainWindow::AddServerToList(QString server, AddServerError *pError) if(isIP) { - InfoQuery *infoQuery = new InfoQuery(this); - infoQuery->query(&info->host, info->port, id); + QueueInfoQuery(info->host, info->port, id); } else { diff --git a/mainwindow.h b/mainwindow.h index f264a00..128c4a4 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -116,6 +117,7 @@ class MainWindow : public QMainWindow explicit MainWindow(QWidget *parent = nullptr); AddServerError CheckServerList(QString server); ServerInfo *AddServerToList(QString server, AddServerError *error = nullptr); + void QueueInfoQuery(QHostAddress host, quint16 port, ServerTableIndexItem *item); void UpdateSelectedItemInfo(bool removeFirst = true, bool updateRules = false); void CreateTableItemOrUpdate(size_t row, size_t col, QTableWidget *table, ServerInfo *info); ServerTableIndexItem *GetServerTableIndexItem(size_t row); @@ -137,7 +139,7 @@ class MainWindow : public QMainWindow bool eventFilter(QObject *object, QEvent *event); public slots: - void ServerInfoReady(InfoReply *, ServerTableIndexItem *); + void ServerInfoReady(const InfoReply *, ServerTableIndexItem *); void PlayerInfoReady(QList *, ServerTableIndexItem *); void RulesInfoReady(QList *, ServerTableIndexItem *); void RconAuthReady(ServerInfo *info, QListqueuedcmds); @@ -177,6 +179,7 @@ private slots: private: Ui::MainWindow *ui; + QThreadPool infoQueryPool; QTimer *updateTimer; void ConnectSlots(); void UpdateInfoTable(ServerInfo *info, bool current = true, QList *list = nullptr); diff --git a/query.cpp b/query.cpp index be43dd7..00c6c12 100644 --- a/query.cpp +++ b/query.cpp @@ -501,18 +501,6 @@ InfoReply::InfoReply(QByteArray response, qint64 ping) } } -InfoQuery::InfoQuery(MainWindow *main) -{ - Worker *worker = new Worker; - worker->moveToThread(&workerThread); - connect(&workerThread, &QThread::finished, worker, &Worker::deleteLater); - connect(&workerThread, &QThread::finished, this, &InfoQuery::deleteLater); - connect(this, &InfoQuery::query, worker, &Worker::getServerInfo); - connect(worker, &Worker::serverInfoReady, main, &MainWindow::ServerInfoReady); - - workerThread.start(); -} - InfoReply *GetInfoReply(QHostAddress host, quint16 port) { QByteArray query; diff --git a/query.h b/query.h index 384249a..3104f09 100644 --- a/query.h +++ b/query.h @@ -77,20 +77,6 @@ class RulesInfo QString value; }; -class InfoQuery : public QObject -{ - Q_OBJECT - QThread workerThread; -public: - InfoQuery(MainWindow *main); - ~InfoQuery() { - workerThread.quit(); - workerThread.wait(); - } -signals: - void query(QHostAddress *, quint16, ServerTableIndexItem *item); -}; - class PlayerQuery : public QObject { Q_OBJECT @@ -127,4 +113,3 @@ QList *GetRulesReply(QHostAddress, quint16, bool goldsrcSplits = fals QString SecondsToDisplayTime(float time); QString GetStringFromStream(QDataStream &stream); #endif // INFOQUERY - diff --git a/query_slots.cpp b/query_slots.cpp index 5cf156f..145f3dd 100644 --- a/query_slots.cpp +++ b/query_slots.cpp @@ -40,11 +40,8 @@ void MainWindow::TimedUpdate() if(info->queryState == QueryResolveFailed || info->queryState == QueryResolving || info->queryState == QueryRunning) continue; - InfoQuery *infoQuery = new InfoQuery(this); - info->cleanHashTable(); - - infoQuery->query(&info->host, info->port, id); + QueueInfoQuery(info->host, info->port, id); } if(run % 60 == 0) { @@ -426,7 +423,7 @@ void MainWindow::UpdateInfoTable(ServerInfo *info, bool current, QListui->browserTable; @@ -444,8 +441,6 @@ void MainWindow::ServerInfoReady(InfoReply *reply, ServerTableIndexItem *indexCe if(row == -1) { - if(reply) - delete reply; return; } @@ -564,7 +559,6 @@ void MainWindow::ServerInfoReady(InfoReply *reply, ServerTableIndexItem *indexCe this->CreateTableItemOrUpdate(row, kBrowserColMap, browserTable, info); this->CreateTableItemOrUpdate(row, kBrowserColPlayerCount, browserTable, info); - delete reply; } else { @@ -576,8 +570,6 @@ void MainWindow::ServerInfoReady(InfoReply *reply, ServerTableIndexItem *indexCe connect(pingCheck, &PingCheck::finished, this, &MainWindow::HostReachabilityReady); pingCheck->check(info->hostPort, indexCell); - if(reply) - delete reply; } this->UpdateInfoTable(info, (row == this->ui->browserTable->currentRow())); this->ApplyBrowserFilter(); diff --git a/serverinfo.cpp b/serverinfo.cpp index 9721d58..84a1609 100644 --- a/serverinfo.cpp +++ b/serverinfo.cpp @@ -126,8 +126,7 @@ void HostQueryResult::HostInfoResolved(QHostInfo hostInfo) this->info->GetCountryFlag(); - InfoQuery *infoQuery = new InfoQuery(this->mainWindow); - infoQuery->query(& this->info->host, this->info->port, this->id); + this->mainWindow->QueueInfoQuery(this->info->host, this->info->port, this->id); this->deleteLater(); return; } diff --git a/updatechecker.cpp b/updatechecker.cpp index 58480ae..85cf899 100644 --- a/updatechecker.cpp +++ b/updatechecker.cpp @@ -120,11 +120,13 @@ void UpdateChecker::onReplyFinished(QNetworkReply *reply) // For same version (dev builds), compare commit hashes bool isDifferentCommit = false; - if(!isNewer && !targetCommit.isEmpty()) + if(!isNewer && remoteVersion == APP_VERSION_STRING && + QRegularExpression("^[0-9a-fA-F]{40}$").match(targetCommit).hasMatch()) { QString localCommit = APP_COMMIT_HASH_FULL; - // target_commitish is the full SHA; compare with our full hash - if(localCommit != "unknown" && targetCommit != localCommit) + // Only compare commits when the build has a real full Git SHA. + if(QRegularExpression("^[0-9a-fA-F]{40}$").match(localCommit).hasMatch() && + targetCommit.compare(localCommit, Qt::CaseInsensitive) != 0) isDifferentCommit = true; } diff --git a/version.h b/version.h index ce31b32..aa2a20c 100644 --- a/version.h +++ b/version.h @@ -1,11 +1,15 @@ #ifndef VERSION_H #define VERSION_H -#define APP_VERSION_STRING "1.0.0" +#ifdef SOURCEADMINTOOL_GENERATED_VERSION +#include +#else +#define APP_VERSION_STRING "1.1.1" #define APP_VERSION_MAJOR 1 -#define APP_VERSION_MINOR 0 -#define APP_VERSION_PATCH 0 +#define APP_VERSION_MINOR 1 +#define APP_VERSION_PATCH 1 #define APP_COMMIT_HASH "dev" #define APP_COMMIT_HASH_FULL "dev" +#endif #endif // VERSION_H diff --git a/version.h.in b/version.h.in index 7f5c3a4..5a3dba9 100644 --- a/version.h.in +++ b/version.h.in @@ -1,5 +1,5 @@ -#ifndef VERSION_H -#define VERSION_H +#ifndef GENERATED_VERSION_H +#define GENERATED_VERSION_H #define APP_VERSION_STRING "@PROJECT_VERSION@" #define APP_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ @@ -8,4 +8,4 @@ #define APP_COMMIT_HASH "@GIT_COMMIT_HASH@" #define APP_COMMIT_HASH_FULL "@GIT_COMMIT_HASH_FULL@" -#endif // VERSION_H +#endif // GENERATED_VERSION_H diff --git a/worker.cpp b/worker.cpp index 746d42c..330b31a 100644 --- a/worker.cpp +++ b/worker.cpp @@ -3,13 +3,6 @@ #include "serverinfo.h" #include -void Worker::getServerInfo(QHostAddress *host, quint16 port, ServerTableIndexItem *item) -{ - InfoReply *reply = GetInfoReply(*host, port); - emit serverInfoReady(reply, item); - this->currentThread()->quit(); -} - void Worker::getPlayerInfo(QHostAddress *host, quint16 port, ServerTableIndexItem *item) { bool goldsrcSplits = item->GetServerInfo()->goldsrc; diff --git a/worker.h b/worker.h index 06670f2..3746e0e 100644 --- a/worker.h +++ b/worker.h @@ -16,13 +16,11 @@ class Worker : public QThread Q_OBJECT public slots: - void getServerInfo(QHostAddress *host, quint16 port, ServerTableIndexItem *item); void getPlayerInfo(QHostAddress *host, quint16 port, ServerTableIndexItem *item); void getRulesInfo(QHostAddress *host, quint16 port, ServerTableIndexItem *item); void setupUPnP(LogHandler *); signals: - void serverInfoReady(InfoReply *reply, ServerTableIndexItem *item); void playerInfoReady(QList *, ServerTableIndexItem *item); void rulesInfoReady(QList *, ServerTableIndexItem *item); void UPnPReady(); From 8d2765ffff7fe68f943867fa10cca25821425aed Mon Sep 17 00:00:00 2001 From: "Alexandru Vlad (Scai)" <59282365+alexevladgabriel@users.noreply.github.com> Date: Sun, 22 Nov 2026 10:22:00 +0200 Subject: [PATCH 2/2] ci: build with Qt 6.9.3 so macOS links on the macOS 26 SDK macos-latest is now macos-26, whose SDK no longer ships the AGL framework. Qt 6.9.0's FindWrapOpenGL.cmake falls back to '-framework AGL' and the link fails; Qt 6.9.2 removed that. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5aaf8f5..fdac2b8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -48,7 +48,7 @@ jobs: uses: jurplel/install-qt-action@v4 with: arch: ${{ matrix.qt_arch }} - version: '6.9.0' + version: '6.9.3' - name: Configure if: "!startsWith(runner.os, 'Windows')"