From b1662eddfa3ba32131ef47ec58e11e23ca7fd3fc Mon Sep 17 00:00:00 2001 From: berrux_dev Date: Sat, 21 Nov 2026 09:25:55 +0100 Subject: [PATCH] Clean up stale comments and blank lines in FTC/FTS and nglapplication unit-test Drop the Qt6-migration explanatory comments (rtiddsgen setter notes, Log4Qt/BUILDING_NGLLOGGER notes, the INTERFACE-to-STATIC note, the return_loan comment block) and the stray blank lines. No code changes: this is the state the last full green run (build + 22/22 ctest + coverage + DEB) was built from. --- .../Lts/DDS/FTC/CMakeLists.txt | 3 -- .../Lts/DDS/FTC/abstract_requester.cpp | 2 - .../Lts/DDS/FTC/abstract_requester.h | 2 - .../Lts/DDS/FTC/generic_ftc.h | 1 - .../Lts/DDS/FTC/generic_ftc_impl.h | 35 +---------------- .../Lts/DDS/FTC/generic_ftc_threading.cpp | 39 ------------------- .../Lts/DDS/FTC/generic_ftc_threading.h | 12 ------ .../Lts/DDS/FTS/generic_fts.h | 3 -- .../Lts/DDS/FTS/generic_fts_impl.h | 4 -- .../nglapplication/unit-test/CMakeLists.txt | 6 +-- 10 files changed, 3 insertions(+), 104 deletions(-) diff --git a/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/CMakeLists.txt b/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/CMakeLists.txt index 2f03db9f1..a01b80e59 100755 --- a/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/CMakeLists.txt +++ b/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/CMakeLists.txt @@ -4,10 +4,7 @@ # $Author$ # - # ddsftc - Changed from INTERFACE to STATIC library to fix source path issues -# When INTERFACE libraries provide sources, CMake compiles them in the consuming -# target's directory context, causing path resolution issues with relative paths ADD_LIBRARY(ddsftc STATIC ${CMAKE_CURRENT_SOURCE_DIR}/generic_ftc.h ${CMAKE_CURRENT_SOURCE_DIR}/generic_ftc.cpp diff --git a/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/abstract_requester.cpp b/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/abstract_requester.cpp index fff2eb65b..d0174084e 100755 --- a/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/abstract_requester.cpp +++ b/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/abstract_requester.cpp @@ -1,6 +1,4 @@ - #include "abstract_requester.h" - Request2::Request2():QObject(){} diff --git a/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/abstract_requester.h b/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/abstract_requester.h index 15c61633f..0e644dbf3 100755 --- a/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/abstract_requester.h +++ b/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/abstract_requester.h @@ -1,10 +1,8 @@ #pragma once #include - #include - class DDSFTCCORE_EXPORT Request2 : public QObject { Q_OBJECT diff --git a/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/generic_ftc.h b/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/generic_ftc.h index 99f15c153..e243d9995 100755 --- a/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/generic_ftc.h +++ b/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/generic_ftc.h @@ -9,7 +9,6 @@ #pragma once #include - #include class Request2; diff --git a/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/generic_ftc_impl.h b/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/generic_ftc_impl.h index 1018c90a7..8c6052924 100644 --- a/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/generic_ftc_impl.h +++ b/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/generic_ftc_impl.h @@ -20,11 +20,9 @@ #include #include #include - #include #include - namespace FTC { template @@ -114,7 +112,6 @@ public: preInit(); } - ~GenericFtcImpl() { Q_ASSERT(!m_dying); @@ -154,8 +151,6 @@ public: } } - - struct ClassicRequest { connext::WriteSample sample; @@ -164,14 +159,12 @@ public: int uniqueId = 0; }; - bool requestDataClassic(const RequestTopic &requestTopic, const char *replySlot, const char *errorSlot, int &uniqueId) override { Q_ASSERT(!m_dying); - ClassicRequest request; if (!checkSlots(request, replySlot, errorSlot)) return false; @@ -180,19 +173,14 @@ public: uniqueId = request.uniqueId; createThread(); - { std::lock_guard l(m_requestMutex); m_classicRequests.push(request); } - runThread(); - return true; } - - template struct ModernRequest { @@ -201,14 +189,11 @@ public: Request2 *requestWatcher; }; - std::future requestDataModern(const RequestTopic &requestTopic, Request2 *requestWatcher) override { Q_ASSERT(!m_dying); - std::promise promise; std::future future = promise.get_future(); - connext::WriteSample sample; sample.set_data(requestTopic); @@ -220,7 +205,6 @@ public: } runThread(); - return future; } @@ -231,36 +215,28 @@ private: return QString::fromUtf8(TopicNameHelper::functionTopicName()); } - int partitionId() const override { return m_partitionId; } - QString partitionType() const override { return QString::fromStdString(m_partitionType); } - std::unique_ptr > requester; // in-thread! - void cleanupThread() override // in-thread! { // called in-thread while thread is preparing to immediately shut down (after this call) and cleans everything that was created also in-thread requester.reset(); } - void threadDone() override { // called after the thread is done and before any new threads may be created // that's why there's no need to lock the mutex here - // NOTE: not called on ctor! - // NOTE: no need to lock as there is no thread anymore at this point - for (; !m_modernRequests.empty(); m_modernRequests.pop()) { ModernRequest &request = m_modernRequests.front(); @@ -278,7 +254,6 @@ private: } } - void work() override // in-thread! { try @@ -291,8 +266,7 @@ private: { fprintf(stderr, "[!] GenericFtc::work: called while marked as no work available! run? %d (%s)\n", isRun(), threadName().toStdString().c_str()); } - setWorkAvailable(false); // NOTE: no need to lock as we're inside the thread and it is guaranteed that we don't hit the condition wait while writing to the variable - // lock + setWorkAvailable(false); { std::lock_guard l(m_requestMutex); @@ -371,14 +345,12 @@ private: } } - template ::value, int>::type = 0> static inline bool isInProgress(const connext::Sample &reply) { return (reply.data().replyState() == Core::FtReplyState::InProgress); } - template ::value, int>::type = 0> static inline bool isInProgress(const connext::Sample &) { @@ -500,10 +472,6 @@ private: QTimer::singleShot(0, request.requestWatcher, &Request2::finished); return; - - /* No need to call replies.return_loan(); - * the destructor takes care of doing it every time replies goes out of scope - */ } } // ------------------------------------------------------------------------------------------------------------- @@ -557,7 +525,6 @@ private: } // ------------------------------------------------------------------------------------------------------------- - // for classic requests: QObject *m_objToInform; int m_uniqueId { 0 }; diff --git a/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/generic_ftc_threading.cpp b/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/generic_ftc_threading.cpp index ba833e5c2..b9a7e12e3 100755 --- a/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/generic_ftc_threading.cpp +++ b/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/generic_ftc_threading.cpp @@ -53,18 +53,10 @@ void Threading::preInit() const m_partitionId = partitionId(); m_partitionType = partitionType(); - - - const QString base(QStringLiteral("F%1%2").arg(m_partitionType.left(1)).arg(m_partitionId)); - - const int baseLen = base.length(); const int maxLen = 16 - 1 - baseLen; - - - if (maxLen < 1) { Q_ASSERT(false); @@ -96,8 +88,6 @@ void Threading::preInit() const } int wordsLeft = words.count(); - - if (wordsLeft < 1) { Q_ASSERT(false); @@ -124,25 +114,16 @@ void Threading::preInit() const } const int maxWordLen = lenRest / wordsLeft; - - - - - if (words.isEmpty()) { Q_ASSERT(false); break; } - name += words.takeFirst().left(maxWordLen); - wordsLeft--; } - - const int finalLeft = maxLen - name.size(); if (finalLeft < 0 || (finalLeft > 0 && functionTopicName().length() > maxLen)) { @@ -157,48 +138,36 @@ void Threading::preInit() const m_threadName = QStringLiteral("%1%2[%3]").arg(base, name).arg(QRandomGenerator::global()->bounded(0x100000000LL), 8, 16, QLatin1Char('0')); } - const QString &Threading::threadName() const { if (m_threadName.isEmpty()) { - Q_ASSERT(false); } - return m_threadName; } - const char *Threading::posixThreadName() const { if (m_posixThreadName.empty()) { m_posixThreadName = threadName().left(15).toStdString(); } - return m_posixThreadName.c_str(); } - void Threading::createThread() { if (!isRun()) { if (m_thread.joinable()) { - m_condition.notify_all(); m_thread.join(); threadDone(); - } - m_alreadyThreaded = 0; - - setRun(true); - m_thread = std::thread(&Threading::run, this, threadName()); #ifdef Q_OS_LINUX @@ -213,7 +182,6 @@ void Threading::createThread() void Threading::runThread() { m_used = true; - Q_ASSERT(m_createThreadCalledBefore); m_createThreadCalledBefore = false; @@ -243,7 +211,6 @@ void Threading::runThread() if (workAvailable || working) { - m_threadLifetime->start(); return; } @@ -253,13 +220,10 @@ void Threading::runThread() if (!run) { - Q_ASSERT(false); return; } - - { std::lock_guard l(m_conditionMutex); setRun(false); @@ -271,7 +235,6 @@ void Threading::runThread() m_threadLifetime->start(); } - void Threading::run(const QString &threadName) { Q_ASSERT(m_alreadyThreaded == 0); @@ -286,8 +249,6 @@ void Threading::run(const QString &threadName) { { std::unique_lock conditionLock(m_conditionMutex); - - m_condition.wait(conditionLock, [this]{ return (isWorkAvailable() || !isRun()); }); } diff --git a/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/generic_ftc_threading.h b/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/generic_ftc_threading.h index 397a8f00b..1ab42c8e8 100755 --- a/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/generic_ftc_threading.h +++ b/qt6-after/qt6-migrated-legatus/Lts/DDS/FTC/generic_ftc_threading.h @@ -37,26 +37,16 @@ public: protected: void preInit() const; - - void createThread(); void runThread(); - - inline bool isRun() const { return (m_run != 0); } inline void setRun(bool run) { m_run = (run ? 1 : 0); } - - inline void setWorkAvailable(bool workAvailable) { m_workAvailable = (workAvailable ? 1 : 0); } inline bool isWorkAvailable() const { return (m_workAvailable != 0); } - - inline void setWorking(bool working) { m_isWorking = (working ? 1 : 0); } inline bool isWorking() const { return (m_isWorking != 0); } - const QString &threadName() const; inline const char *posixThreadName() const; - virtual void work() = 0; virtual QString functionTopicName() const = 0; virtual int partitionId() const = 0; @@ -68,7 +58,6 @@ protected: { if (!isRun()) { - throw CancelationPointReached(); } } @@ -79,7 +68,6 @@ private: inline bool isCleanupNeeded() const { return (m_cleanupNeeded != 0); } inline void setCleanupNeeded(bool cleanupNeeded) { m_cleanupNeeded = (cleanupNeeded ? 1 : 0); } void run(const QString &threadName); - std::unique_ptr m_threadLifetime; QAtomicInt m_run { 0 }; diff --git a/qt6-after/qt6-migrated-legatus/Lts/DDS/FTS/generic_fts.h b/qt6-after/qt6-migrated-legatus/Lts/DDS/FTS/generic_fts.h index aa85aaf05..df4a7f400 100755 --- a/qt6-after/qt6-migrated-legatus/Lts/DDS/FTS/generic_fts.h +++ b/qt6-after/qt6-migrated-legatus/Lts/DDS/FTS/generic_fts.h @@ -13,9 +13,6 @@ #endif #include - - - namespace FTS { diff --git a/qt6-after/qt6-migrated-legatus/Lts/DDS/FTS/generic_fts_impl.h b/qt6-after/qt6-migrated-legatus/Lts/DDS/FTS/generic_fts_impl.h index 8b0b305fb..022cd91c9 100644 --- a/qt6-after/qt6-migrated-legatus/Lts/DDS/FTS/generic_fts_impl.h +++ b/qt6-after/qt6-migrated-legatus/Lts/DDS/FTS/generic_fts_impl.h @@ -63,12 +63,8 @@ private: void sendReplyState(Core::FtReplyState replyState, const rti::core::SampleIdentity &requestSampleIdentity) { connext::WriteSample reply; - // rtiddsgen -stl generates plain public data members, so the reply - // state is assigned directly instead of the old setter call. reply.data().replyState = replyState; - // FtReplyState doesn't exist anymore with rtiddsgen 7.7 - the - // enum values are directly available in Core::FtReplyState. bool bLastTelegram = ((replyState != Core::FtReplyState::InProgress) && (replyState != Core::FtReplyState::NotStarted)); m_replier->send_reply(reply, requestSampleIdentity, bLastTelegram); diff --git a/qt6-after/qt6-migrated-legatus/Z/src/nglapplication/unit-test/CMakeLists.txt b/qt6-after/qt6-migrated-legatus/Z/src/nglapplication/unit-test/CMakeLists.txt index 0399331cd..99773424e 100644 --- a/qt6-after/qt6-migrated-legatus/Z/src/nglapplication/unit-test/CMakeLists.txt +++ b/qt6-after/qt6-migrated-legatus/Z/src/nglapplication/unit-test/CMakeLists.txt @@ -7,12 +7,10 @@ if (NOT BUILD_TESTING) endif() # --- nglapplication: nglcoreapplication logger handler -# --- (Log4Qt-independent; works in the Log4Qt-less (stub) build) + if (TARGET nglcoreapplication) ADD_EXECUTABLE(nglcoreapplication_unit_test nglcoreapplication_unit_test.cpp) - # NGLLogger.h (the AlreadyCreatedError type thrown by createNGLRootLogger) - # refuses to be included outside the NGLLogger library unless - # BUILDING_NGLLOGGER is defined (same pattern as NGLLogger/CMakeLists.txt) + TARGET_COMPILE_DEFINITIONS(nglcoreapplication_unit_test PRIVATE BUILDING_NGLLOGGER) TARGET_LINK_LIBRARIES(nglcoreapplication_unit_test nglcoreapplication