From fc27b8dcbba9d9cb78922ec2bd4440f5ec19c639 Mon Sep 17 00:00:00 2001 From: bdm-oslandia Date: Tue, 26 Nov 2024 07:26:38 +0100 Subject: [PATCH 01/15] fix(qgisserver): suppress wait in fcgi response destructor In the previous version, the response destructor waited for the monitoring thread to end that may induce a 333ms sleep each time. We fix that by using a classic ptr to separate the thread and the response lifecycles. --- src/server/qgsfcgiserverresponse.cpp | 53 ++++++++++++++++++++++------ src/server/qgsfcgiserverresponse.h | 21 ++++++++--- 2 files changed, 59 insertions(+), 15 deletions(-) diff --git a/src/server/qgsfcgiserverresponse.cpp b/src/server/qgsfcgiserverresponse.cpp index 7a61e34ef50d..a70e4eb59670 100644 --- a/src/server/qgsfcgiserverresponse.cpp +++ b/src/server/qgsfcgiserverresponse.cpp @@ -54,13 +54,11 @@ typedef struct QgsFCGXStreamData } QgsFCGXStreamData; #endif -QgsSocketMonitoringThread::QgsSocketMonitoringThread( bool *isResponseFinished, QgsFeedback *feedback ) - : mIsResponseFinished( isResponseFinished ) - , mFeedback( feedback ) +QgsSocketMonitoringThread::QgsSocketMonitoringThread( QgsFeedback *feedback ) + : mFeedback( feedback ) , mIpcFd( -1 ) { setObjectName( "FCGI socket monitor" ); - Q_ASSERT( mIsResponseFinished ); Q_ASSERT( mFeedback ); #if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID) @@ -73,20 +71,29 @@ QgsSocketMonitoringThread::QgsSocketMonitoringThread( bool *isResponseFinished, } else { - QgsMessageLog::logMessage( QStringLiteral( "FCGI_stdin stream data is null! Socket monitoring disable." ), + QgsMessageLog::logMessage( QStringLiteral( "FCGI_stdin stream data is null! Socket monitoring disabled." ), QStringLiteral( "FCGIServer" ), Qgis::MessageLevel::Warning ); } } else { - QgsMessageLog::logMessage( QStringLiteral( "FCGI_stdin is null! Socket monitoring disable." ), + QgsMessageLog::logMessage( QStringLiteral( "FCGI_stdin is null! Socket monitoring disabled." ), QStringLiteral( "FCGIServer" ), Qgis::MessageLevel::Warning ); } + + // Suicide the thread when it ends + connect( this, &QThread::finished, this, &QThread::deleteLater ); + #endif } +void QgsSocketMonitoringThread::setResponseFinished( bool responseFinished ) +{ + mIsResponseFinished = responseFinished; +} + void QgsSocketMonitoringThread::run( ) { if ( mIpcFd < 0 ) @@ -99,7 +106,7 @@ void QgsSocketMonitoringThread::run( ) #if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID) char c; - while ( !*mIsResponseFinished ) + while ( !mIsResponseFinished ) { const ssize_t x = recv( mIpcFd, &c, 1, MSG_PEEK | MSG_DONTWAIT ); // see https://stackoverflow.com/a/12402596 if ( x < 0 ) @@ -118,7 +125,7 @@ void QgsSocketMonitoringThread::run( ) QThread::msleep( 333L ); } - if ( *mIsResponseFinished ) + if ( mIsResponseFinished ) { QgsDebugMsgLevel( QStringLiteral( "FCGIServer: socket monitoring quits normally." ), 2 ); } @@ -141,15 +148,39 @@ QgsFcgiServerResponse::QgsFcgiServerResponse( QgsServerRequest::Method method ) mBuffer.open( QIODevice::ReadWrite ); setDefaultHeaders(); - mSocketMonitoringThread = std::make_unique( &mFinished, mFeedback.get() ); + // This is not a unique_ptr because we want the response to not depend on the thread lifecycle. + mSocketMonitoringThread = new QgsSocketMonitoringThread( mFeedback.get() ); mSocketMonitoringThread->start(); } +QgsFcgiServerResponse::QgsFcgiServerResponse( const QgsFcgiServerResponse © ) + : mFinished( copy.mFinished ) + , mHeadersSent( copy.mHeadersSent ) + , mMethod( copy.mMethod ) + , mStatusCode( copy.mStatusCode ) + , mSocketMonitoringThread( nullptr ) + , mFeedback( nullptr ) +{ +} + +QgsFcgiServerResponse &QgsFcgiServerResponse::operator =( const QgsFcgiServerResponse © ) +{ + mFinished = copy.mFinished; + mHeadersSent = copy.mHeadersSent; + mMethod = copy.mMethod; + mStatusCode = copy.mStatusCode; + mSocketMonitoringThread = nullptr; + mFeedback = nullptr; + + return *this; +} + QgsFcgiServerResponse::~QgsFcgiServerResponse() { mFinished = true; - mSocketMonitoringThread->exit(); - mSocketMonitoringThread->wait(); + if ( mSocketMonitoringThread ) + // This will allow the thread to finish sleeping and exit its while loop in the background, without us needing to wait for it to finish. + mSocketMonitoringThread->setResponseFinished( mFinished ); } void QgsFcgiServerResponse::removeHeader( const QString &key ) diff --git a/src/server/qgsfcgiserverresponse.h b/src/server/qgsfcgiserverresponse.h index 25e6025d3bf3..859a41291b1d 100644 --- a/src/server/qgsfcgiserverresponse.h +++ b/src/server/qgsfcgiserverresponse.h @@ -45,11 +45,13 @@ class QgsSocketMonitoringThread: public QThread * \param isResponseFinished * \param feedback */ - QgsSocketMonitoringThread( bool *isResponseFinished, QgsFeedback *feedback ); + QgsSocketMonitoringThread( QgsFeedback *feedback ); void run( ); + void setResponseFinished( bool responseFinished ); + private: - bool *mIsResponseFinished = nullptr; + bool mIsResponseFinished = false; QgsFeedback *mFeedback = nullptr; int mIpcFd = -1; }; @@ -68,7 +70,18 @@ class SERVER_EXPORT QgsFcgiServerResponse: public QgsServerResponse * \param method The HTTP method (Get by default) */ QgsFcgiServerResponse( QgsServerRequest::Method method = QgsServerRequest::GetMethod ); - virtual ~QgsFcgiServerResponse(); + + /** + * Dummy copy constructor. Needed because of QgsSocketMonitoringThread ptr + */ + QgsFcgiServerResponse( const QgsFcgiServerResponse © ); + + /** + * Dummy operator = . Needed because of QgsSocketMonitoringThread ptr + */ + QgsFcgiServerResponse &operator = ( const QgsFcgiServerResponse © ); + + virtual ~QgsFcgiServerResponse() override; void setHeader( const QString &key, const QString &value ) override; @@ -117,7 +130,7 @@ class SERVER_EXPORT QgsFcgiServerResponse: public QgsServerResponse QgsServerRequest::Method mMethod; int mStatusCode = 0; - std::unique_ptr mSocketMonitoringThread; + QgsSocketMonitoringThread *mSocketMonitoringThread; std::unique_ptr mFeedback; }; From d8184ab438367542448d1895b239b94144a847d5 Mon Sep 17 00:00:00 2001 From: bdm-oslandia Date: Thu, 28 Nov 2024 16:41:05 +0100 Subject: [PATCH 02/15] fixup! fix(qgisserver): suppress wait in fcgi response destructor --- src/server/qgsfcgiserverresponse.cpp | 22 ---------------------- src/server/qgsfcgiserverresponse.h | 12 ++---------- 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/src/server/qgsfcgiserverresponse.cpp b/src/server/qgsfcgiserverresponse.cpp index a70e4eb59670..b62ffaa4f826 100644 --- a/src/server/qgsfcgiserverresponse.cpp +++ b/src/server/qgsfcgiserverresponse.cpp @@ -153,28 +153,6 @@ QgsFcgiServerResponse::QgsFcgiServerResponse( QgsServerRequest::Method method ) mSocketMonitoringThread->start(); } -QgsFcgiServerResponse::QgsFcgiServerResponse( const QgsFcgiServerResponse © ) - : mFinished( copy.mFinished ) - , mHeadersSent( copy.mHeadersSent ) - , mMethod( copy.mMethod ) - , mStatusCode( copy.mStatusCode ) - , mSocketMonitoringThread( nullptr ) - , mFeedback( nullptr ) -{ -} - -QgsFcgiServerResponse &QgsFcgiServerResponse::operator =( const QgsFcgiServerResponse © ) -{ - mFinished = copy.mFinished; - mHeadersSent = copy.mHeadersSent; - mMethod = copy.mMethod; - mStatusCode = copy.mStatusCode; - mSocketMonitoringThread = nullptr; - mFeedback = nullptr; - - return *this; -} - QgsFcgiServerResponse::~QgsFcgiServerResponse() { mFinished = true; diff --git a/src/server/qgsfcgiserverresponse.h b/src/server/qgsfcgiserverresponse.h index 859a41291b1d..4d0d404549a7 100644 --- a/src/server/qgsfcgiserverresponse.h +++ b/src/server/qgsfcgiserverresponse.h @@ -71,16 +71,6 @@ class SERVER_EXPORT QgsFcgiServerResponse: public QgsServerResponse */ QgsFcgiServerResponse( QgsServerRequest::Method method = QgsServerRequest::GetMethod ); - /** - * Dummy copy constructor. Needed because of QgsSocketMonitoringThread ptr - */ - QgsFcgiServerResponse( const QgsFcgiServerResponse © ); - - /** - * Dummy operator = . Needed because of QgsSocketMonitoringThread ptr - */ - QgsFcgiServerResponse &operator = ( const QgsFcgiServerResponse © ); - virtual ~QgsFcgiServerResponse() override; void setHeader( const QString &key, const QString &value ) override; @@ -123,6 +113,8 @@ class SERVER_EXPORT QgsFcgiServerResponse: public QgsServerResponse QgsFeedback *feedback() const override { return mFeedback.get(); } private: + Q_DISABLE_COPY( QgsFcgiServerResponse ) + QMap mHeaders; QBuffer mBuffer; bool mFinished = false; From 1e68718625001c29f26038179b56f9bd7954cea8 Mon Sep 17 00:00:00 2001 From: bdm-oslandia Date: Thu, 28 Nov 2024 16:42:26 +0100 Subject: [PATCH 03/15] clang-tidy: remove clang-analyzer-optin.cplusplus.VirtualCall warning in QgsFcgiServerResponse --- scripts/cppcheck.sh | 6 ++++-- src/server/qgsfcgiserverresponse.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/cppcheck.sh b/scripts/cppcheck.sh index 974feec5d792..c78c8fededb4 100755 --- a/scripts/cppcheck.sh +++ b/scripts/cppcheck.sh @@ -14,10 +14,12 @@ case $SCRIPT_DIR in ;; esac +SRC_DIR=${1:-../src} + LOG_FILE=/tmp/cppcheck_qgis.txt rm -f ${LOG_FILE} -echo "Checking ${SCRIPT_DIR}/../src ..." +echo "Checking ${SCRIPT_DIR}/${SRC_DIR} ..." # qgsgcptransformer.cpp causes an effective hang on newer cppcheck! @@ -50,7 +52,7 @@ cppcheck --library=qt.cfg --inline-suppr \ -DBUILTIN_UNREACHABLE="__builtin_unreachable();" \ -i src/analysis/georeferencing/qgsgcptransformer.cpp \ -j $(nproc) \ - ${SCRIPT_DIR}/../src \ + ${SCRIPT_DIR}/${SRC_DIR} \ >>${LOG_FILE} 2>&1 & PID=$! diff --git a/src/server/qgsfcgiserverresponse.cpp b/src/server/qgsfcgiserverresponse.cpp index b62ffaa4f826..e422d6960e60 100644 --- a/src/server/qgsfcgiserverresponse.cpp +++ b/src/server/qgsfcgiserverresponse.cpp @@ -305,5 +305,5 @@ void QgsFcgiServerResponse::truncate() void QgsFcgiServerResponse::setDefaultHeaders() { - setHeader( QStringLiteral( "Server" ), QStringLiteral( " QGIS FCGI server - QGIS version %1" ).arg( Qgis::version() ) ); + mHeaders.insert( QStringLiteral( "Server" ), QStringLiteral( " QGIS FCGI server - QGIS version %1" ).arg( Qgis::version() ) ); } From 56653a5c66c9618e7bb2d8d63e3d5d03daf59335 Mon Sep 17 00:00:00 2001 From: bdm-oslandia Date: Thu, 28 Nov 2024 16:54:20 +0100 Subject: [PATCH 04/15] fixup! fix(qgisserver): suppress wait in fcgi response destructor --- src/server/qgsfcgiserverresponse.cpp | 2 +- src/server/qgsfcgiserverresponse.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/server/qgsfcgiserverresponse.cpp b/src/server/qgsfcgiserverresponse.cpp index e422d6960e60..b1da4ab2160e 100644 --- a/src/server/qgsfcgiserverresponse.cpp +++ b/src/server/qgsfcgiserverresponse.cpp @@ -54,7 +54,7 @@ typedef struct QgsFCGXStreamData } QgsFCGXStreamData; #endif -QgsSocketMonitoringThread::QgsSocketMonitoringThread( QgsFeedback *feedback ) +QgsSocketMonitoringThread::QgsSocketMonitoringThread( std::shared_ptr feedback ) : mFeedback( feedback ) , mIpcFd( -1 ) { diff --git a/src/server/qgsfcgiserverresponse.h b/src/server/qgsfcgiserverresponse.h index 4d0d404549a7..92b4ece80b91 100644 --- a/src/server/qgsfcgiserverresponse.h +++ b/src/server/qgsfcgiserverresponse.h @@ -45,14 +45,14 @@ class QgsSocketMonitoringThread: public QThread * \param isResponseFinished * \param feedback */ - QgsSocketMonitoringThread( QgsFeedback *feedback ); + QgsSocketMonitoringThread( std::shared_ptr feedback ); void run( ); void setResponseFinished( bool responseFinished ); private: bool mIsResponseFinished = false; - QgsFeedback *mFeedback = nullptr; + std::shared_ptr mFeedback; int mIpcFd = -1; }; @@ -123,7 +123,7 @@ class SERVER_EXPORT QgsFcgiServerResponse: public QgsServerResponse int mStatusCode = 0; QgsSocketMonitoringThread *mSocketMonitoringThread; - std::unique_ptr mFeedback; + std::shared_ptr mFeedback; }; #endif From 1a2a895959ab7e446b5dc8fcb869d37833ea6541 Mon Sep 17 00:00:00 2001 From: bdm-oslandia Date: Thu, 28 Nov 2024 17:05:18 +0100 Subject: [PATCH 05/15] fixup! fix(qgisserver): suppress wait in fcgi response destructor --- src/server/qgsfcgiserverresponse.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/qgsfcgiserverresponse.cpp b/src/server/qgsfcgiserverresponse.cpp index b1da4ab2160e..0784dc9ea008 100644 --- a/src/server/qgsfcgiserverresponse.cpp +++ b/src/server/qgsfcgiserverresponse.cpp @@ -149,7 +149,7 @@ QgsFcgiServerResponse::QgsFcgiServerResponse( QgsServerRequest::Method method ) setDefaultHeaders(); // This is not a unique_ptr because we want the response to not depend on the thread lifecycle. - mSocketMonitoringThread = new QgsSocketMonitoringThread( mFeedback.get() ); + mSocketMonitoringThread = new QgsSocketMonitoringThread( mFeedback ); mSocketMonitoringThread->start(); } From cb562470d393c92848f3dccc9a3178fa5c5bf72d Mon Sep 17 00:00:00 2001 From: bdm-oslandia Date: Fri, 29 Nov 2024 12:01:57 +0100 Subject: [PATCH 06/15] debug ogc test --- .github/workflows/ogc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ogc.yml b/.github/workflows/ogc.yml index bd6dd3f82a60..b2e4cef44076 100644 --- a/.github/workflows/ogc.yml +++ b/.github/workflows/ogc.yml @@ -89,7 +89,7 @@ jobs: run: | source venv/bin/activate && ./pyogctest/pyogctest.py -s wms130 -e docker compose -f .ci/ogc/docker-compose.yml up -d - source venv/bin/activate && ./pyogctest/pyogctest.py -n ogc_qgis -s wms130 -v -u http://$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' qgis_server_nginx)/qgisserver_wms130 + source venv/bin/activate && ./pyogctest/pyogctest.py -n ogc_qgis -s wms130 -d -v -u http://$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' qgis_server_nginx)/qgisserver_wms130 env: DOCKER_IMAGE: ${{ steps.docker-build.outputs.imageid }} From 118fa2ecb9b1c449207c2a9173972673a3a30fe4 Mon Sep 17 00:00:00 2001 From: bdm-oslandia Date: Fri, 29 Nov 2024 12:04:57 +0100 Subject: [PATCH 07/15] debug ogc test2 --- .github/workflows/build-macos-qt6.yml | 216 ++++++------ .github/workflows/code_layout.yml | 219 ------------ .github/workflows/flake8.yml | 38 --- .github/workflows/macos-build.yml | 138 -------- .github/workflows/run-tests.yml | 468 +++++++++++++------------- .github/workflows/windows-qt6.yml | 138 -------- 6 files changed, 342 insertions(+), 875 deletions(-) delete mode 100644 .github/workflows/code_layout.yml delete mode 100644 .github/workflows/flake8.yml delete mode 100644 .github/workflows/macos-build.yml delete mode 100644 .github/workflows/windows-qt6.yml diff --git a/.github/workflows/build-macos-qt6.yml b/.github/workflows/build-macos-qt6.yml index 4edf1d8280ec..e4e1ddf5bd92 100644 --- a/.github/workflows/build-macos-qt6.yml +++ b/.github/workflows/build-macos-qt6.yml @@ -1,108 +1,108 @@ ---- -name: 🍎 Build - MacOS Qt6 -on: - # push: - # branches: - # - main - # pull_request: - # release: - # types: ['published'] - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - build: - strategy: - matrix: - include: -# - os: macos-13 -# triplet: x64-osx -# deployment-target: "10.15" - - os: macos-14 - triplet: arm64-osx-dynamic-release - deployment-target: "11.0" - name: build (macos) - runs-on: ${{ matrix.os }} - - steps: - - name: 🐣 Checkout - uses: actions/checkout@v4 - - - name: 🐩 Install CMake and Ninja - uses: lukka/get-cmake@latest - with: - # Pin to specific version to avoid rebuilding too often - # Also helps to avoid spurious build failures like https://github.com/qgis/QGIS/pull/47098 - cmakeVersion: 3.30.4 - - - name: 🎑 Setup vcpkg - id: setup-vcpkg - uses: ./.github/actions/setup-vcpkg - - - name: πŸ”¨ Prepare build env - run: | - brew install automake bison flex gnu-sed create-dmg autoconf-archive nasm libtool fdupes - echo $(brew --prefix bison)/bin >> $GITHUB_PATH - echo $(brew --prefix flex)/bin >> $GITHUB_PATH - echo $(brew --prefix libtool)/bin >> $GITHUB_PATH - - - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - - name: 🍭 Setup XCode - uses: maxim-lobanov/setup-xcode@v1.6.0 - with: - xcode-version: latest-stable - - - name: 🌱 Install dependencies and generate project files - run: | - echo "VCPKG_ROOT: ${VCPKG_ROOT}" - - # Install first only with binarycaching, then deduplicate binaries and replace copies with symlinks. - # Nuget doesn't understand the symlink concept - cmake -S . \ - -G Ninja \ - -B build \ - -D WITH_VCPKG=ON \ - -D BUILD_WITH_QT6=ON \ - -D WITH_QTWEBKIT=OFF \ - -D WITH_BINDINGS=ON \ - -D QGIS_MACAPP_FRAMEWORK=OFF \ - -D VCPKG_TARGET_TRIPLET="${{ matrix.triplet }}" \ - -D VCPKG_HOST_TRIPLET="${{ matrix.triplet }}" \ - -D VCPKG_INSTALL_OPTIONS="--only-binarycaching" \ - -D NUGET_USERNAME=${{ github.actor }} \ - -D NUGET_TOKEN=${{ secrets.GITHUB_TOKEN }} || true - - fdupes -r -1 build/vcpkg_installed/arm64-osx-dynamic/lib | grep libQt | while read line; do master=""; for file in ${line[*]}; do if [[ "x${master}" == "x" ]]; then master=$file; else rm "${file}"; ln -s $(basename "${master}") "${file}"; fi; done; done - - cmake -D VCPKG_INSTALL_OPTIONS="" build - - - name: πŸ“‘ Upload vcpkg build logs - uses: actions/upload-artifact@v4 - if: failure() - with: - name: build-logs-${{ matrix.triplet }} - path: | - ${{ env.VCPKG_ROOT }}/buildtrees/**/*.log - - - name: πŸ“¦ Create SDK - if: github.event_name == 'workflow_dispatch' || github.event_name == 'release' - run: | - ./build/_deps/vcpkg-src/vcpkg export --zip --output-dir=./sdk --x-install-root=./build/vcpkg_installed --x-manifest-root=vcpkg - - - name: πŸ“€ Upload sdk - if: github.event_name == 'workflow_dispatch' || github.event_name == 'release' - uses: actions/upload-artifact@v4 - with: - name: kadas-albireo2-sdk-${{ matrix.triplet }} - path: | - sdk/vcpkg-export-*.zip - - - name: πŸŒ‹ Build - run: | - cmake --build build +# --- +# name: 🍎 Build - MacOS Qt6 +# on: +# # push: +# # branches: +# # - main +# # pull_request: +# # release: +# # types: ['published'] +# workflow_dispatch: + +# concurrency: +# group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} +# cancel-in-progress: true + +# jobs: +# build: +# strategy: +# matrix: +# include: +# # - os: macos-13 +# # triplet: x64-osx +# # deployment-target: "10.15" +# - os: macos-14 +# triplet: arm64-osx-dynamic-release +# deployment-target: "11.0" +# name: build (macos) +# runs-on: ${{ matrix.os }} + +# steps: +# - name: 🐣 Checkout +# uses: actions/checkout@v4 + +# - name: 🐩 Install CMake and Ninja +# uses: lukka/get-cmake@latest +# with: +# # Pin to specific version to avoid rebuilding too often +# # Also helps to avoid spurious build failures like https://github.com/qgis/QGIS/pull/47098 +# cmakeVersion: 3.30.4 + +# - name: 🎑 Setup vcpkg +# id: setup-vcpkg +# uses: ./.github/actions/setup-vcpkg + +# - name: πŸ”¨ Prepare build env +# run: | +# brew install automake bison flex gnu-sed create-dmg autoconf-archive nasm libtool fdupes +# echo $(brew --prefix bison)/bin >> $GITHUB_PATH +# echo $(brew --prefix flex)/bin >> $GITHUB_PATH +# echo $(brew --prefix libtool)/bin >> $GITHUB_PATH + +# - uses: actions/setup-python@v5 +# with: +# python-version: '3.11' + +# - name: 🍭 Setup XCode +# uses: maxim-lobanov/setup-xcode@v1.6.0 +# with: +# xcode-version: latest-stable + +# - name: 🌱 Install dependencies and generate project files +# run: | +# echo "VCPKG_ROOT: ${VCPKG_ROOT}" + +# # Install first only with binarycaching, then deduplicate binaries and replace copies with symlinks. +# # Nuget doesn't understand the symlink concept +# cmake -S . \ +# -G Ninja \ +# -B build \ +# -D WITH_VCPKG=ON \ +# -D BUILD_WITH_QT6=ON \ +# -D WITH_QTWEBKIT=OFF \ +# -D WITH_BINDINGS=ON \ +# -D QGIS_MACAPP_FRAMEWORK=OFF \ +# -D VCPKG_TARGET_TRIPLET="${{ matrix.triplet }}" \ +# -D VCPKG_HOST_TRIPLET="${{ matrix.triplet }}" \ +# -D VCPKG_INSTALL_OPTIONS="--only-binarycaching" \ +# -D NUGET_USERNAME=${{ github.actor }} \ +# -D NUGET_TOKEN=${{ secrets.GITHUB_TOKEN }} || true + +# fdupes -r -1 build/vcpkg_installed/arm64-osx-dynamic/lib | grep libQt | while read line; do master=""; for file in ${line[*]}; do if [[ "x${master}" == "x" ]]; then master=$file; else rm "${file}"; ln -s $(basename "${master}") "${file}"; fi; done; done + +# cmake -D VCPKG_INSTALL_OPTIONS="" build + +# - name: πŸ“‘ Upload vcpkg build logs +# uses: actions/upload-artifact@v4 +# if: failure() +# with: +# name: build-logs-${{ matrix.triplet }} +# path: | +# ${{ env.VCPKG_ROOT }}/buildtrees/**/*.log + +# - name: πŸ“¦ Create SDK +# if: github.event_name == 'workflow_dispatch' || github.event_name == 'release' +# run: | +# ./build/_deps/vcpkg-src/vcpkg export --zip --output-dir=./sdk --x-install-root=./build/vcpkg_installed --x-manifest-root=vcpkg + +# - name: πŸ“€ Upload sdk +# if: github.event_name == 'workflow_dispatch' || github.event_name == 'release' +# uses: actions/upload-artifact@v4 +# with: +# name: kadas-albireo2-sdk-${{ matrix.triplet }} +# path: | +# sdk/vcpkg-export-*.zip + +# - name: πŸŒ‹ Build +# run: | +# cmake --build build diff --git a/.github/workflows/code_layout.yml b/.github/workflows/code_layout.yml deleted file mode 100644 index 542ad51da654..000000000000 --- a/.github/workflows/code_layout.yml +++ /dev/null @@ -1,219 +0,0 @@ -name: 🧹 Code Layout - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -on: - push: - branches: - - master - - release-** - - queued_ltr_backports - pull_request: - -permissions: - contents: read - -env: - DOXYGEN_VERSION: 1.9.8 - -jobs: - documentation_checks: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set up Python 3.10 - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - name: Install requirements - run: | - wget https://www.doxygen.nl/files/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz - tar -xzf doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz - python -m pip install --upgrade pip - pip install autopep8 nose2 mock termcolor - - name: Make - run: | - mkdir build - cd build - cmake -DUSE_CCACHE=OFF -DWITH_CORE=OFF -DWITH_APIDOC=ON -DWITH_ASTYLE=ON -DENABLE_TESTS=ON \ - -DWITH_DOT=NO -DWERROR=ON -DDOXYGEN_EXECUTABLE=../doxygen-${DOXYGEN_VERSION}/bin/doxygen .. - make -j3 apidoc - - name: Run Tests - run: cd build && ctest -V -R PyQgsDocCoverage - - license_check: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Install Requirements - run: | - sudo apt install -y \ - cpanminus - cpanm --notest App::Licensecheck - - - name: Run License Check - run: ./tests/code_layout/test_licenses.sh - - shell_check: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Install Requirements - run: | - sudo apt install -y \ - shellcheck - - - name: Run Shellcheck - run: ./tests/code_layout/test_shellcheck.sh - - banned_keywords_check: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Run Banned Keywords Test - run: ./tests/code_layout/test_banned_keywords.sh - - class_name_check: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Run class naming conventions check - run: ./tests/code_layout/test_class_names.sh - - def_window_title_check: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Def Window Title Test - run: ./tests/code_layout/test_defwindowtitle.sh - - qgsscrollarea_check: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Run QgsScrollArea check - run: ./tests/code_layout/test_qgsscrollarea.sh - - qvariant_no_brace_init: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: No brace initialization of QVariant variables - run: ./tests/code_layout/test_qvariant_no_brace_init.sh - - qt_module_wide_imports: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: No module-wide imports of Qt modules - run: ./tests/code_layout/test_qt_imports.sh - - doxygen_layout_check: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Install Requirements - run: | - sudo apt install -y \ - expect \ - silversearcher-ag - - name: Doxygen Layout Test - run: ./tests/code_layout/test_doxygen_layout.sh - - indentation_check: - if: github.event_name == 'pull_request' - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 100 - - name: Install Requirements - run: | - sudo apt install -y \ - astyle \ - python3-autopep8 \ - flip - - name: Indentation Test - run: ./scripts/verify_indentation.sh HEAD~1 - - spell_check: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install Requirements - run: | - sudo apt install -y \ - expect \ - silversearcher-ag - - - name: Retrieve changed files - uses: tj-actions/changed-files@v45 - id: changed_files - with: - separator: " " - - - name: Spell Test - if: steps.changed_files.outputs.any_changed == 'true' - env: - ALL_CHANGED_FILES: ${{ steps.changed_files.outputs.all_changed_files }} - run: echo "$ALL_CHANGED_FILES" | ./scripts/spell_check/check_spelling.sh - - sip_check: - runs-on: ubuntu-latest - steps: - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - name: Install Requirements - run: | - python -m pip install --upgrade pip - pip install autopep8 nose2 mock termcolor pyyaml - - name: Checkout - uses: actions/checkout@v4 - - name: Sip Checks - run: ./tests/code_layout/sipify/test_sipify.sh - - name: Sip Include Test - run: ./tests/code_layout/sipify/test_sip_include.sh - - name: Sip Files Up To Date - run: ./tests/code_layout/sipify/test_sipfiles.sh - - cppcheck: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install Requirements - run: | - sudo apt install -y cppcheck - - - name: Run cppcheck test - run: ./scripts/cppcheck.sh - - moc_check: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - name: Run Check - run: python3 scripts/includemocs.py src --dry-run diff --git a/.github/workflows/flake8.yml b/.github/workflows/flake8.yml deleted file mode 100644 index bfc13a3dfdb9..000000000000 --- a/.github/workflows/flake8.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: ❄ Flake8 - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -on: - push: - branches: - - master - - release-* - paths: - - '**.py' - pull_request: - paths: - - '**.py' - -permissions: - contents: read - -jobs: - flake8_py3: - name: Python Lint - runs-on: ubuntu-latest - steps: - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: 3.12 - architecture: x64 - - name: Checkout - uses: actions/checkout@v4 - - name: Run flake8 - uses: julianwachholz/flake8-action@v2.0.2 - with: - checkName: 'Python Lint' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/macos-build.yml b/.github/workflows/macos-build.yml deleted file mode 100644 index 2b906bca633d..000000000000 --- a/.github/workflows/macos-build.yml +++ /dev/null @@ -1,138 +0,0 @@ -name: 🍏 Mac OS build - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -on: - push: - branches: - - master - - release-** - - queued_ltr_backports - paths: - pull_request: - branches: - - master - - release-** - - queued_ltr_backports - paths: - -permissions: - contents: read - -env: - QT_VERSION: 5.15.2 - QGIS_DEPS_VERSION: 0.9 - QGIS_DEPS_PATCH_VERSION: 0 - CCACHE_DIR: /Users/runner/work/ccache - BUILD_DIR: /Users/runner/work/QGIS/build-QGIS - # apparently we cannot cache /opt directory as it fails to restore - # so we copy the deps in the home directory - DEPS_CACHE_DIR: /Users/runner/work/deps-cache - -jobs: - mac_os_build: - if: github.repository == 'qgis/QGIS' - runs-on: macos-13 - steps: - - uses: actions/checkout@v4 - - - name: Restore build cache - uses: actions/cache/restore@v4 - with: - path: ${{ env.CCACHE_DIR }} - key: build-ccache-mac-${{Β github.event.pull_request.base.ref || github.ref_name }} - restore-keys: | - build-ccache-mac-master - - - name: Cache Qt - id: cache-qt - uses: actions/cache@v4 - with: - path: ${{ env.DEPS_CACHE_DIR }}/Qt/${{ env.QT_VERSION }} - key: mac-qt-${{ env.QT_VERSION }} - - - name: Restore Qt - if: steps.cache-qt.outputs.cache-hit == 'true' - run: | - sudo mkdir -p /opt - sudo mkdir -p /opt/Qt - sudo cp -r ${DEPS_CACHE_DIR}/Qt/${QT_VERSION} /opt/Qt/${QT_VERSION} - - - name: Download Qt - if: steps.cache-qt.outputs.cache-hit != 'true' - run: | - wget https://qgis.org/downloads/macos/deps/qt-${QT_VERSION}.tar.gz - mkdir -p ${DEPS_CACHE_DIR} - mkdir -p ${DEPS_CACHE_DIR}/Qt - - - # QGIS-deps caching - - name: Cache qgis-deps - id: cache-deps - uses: actions/cache@v4 - with: - path: ${{ env.DEPS_CACHE_DIR }}/QGIS/qgis-deps-${{ env.QGIS_DEPS_VERSION }}.${{ env.QGIS_DEPS_PATCH_VERSION }} - key: mac-qgis-deps-${{ env.QGIS_DEPS_VERSION }}.${{ env.QGIS_DEPS_PATCH_VERSION }} - - - name: Restore qgis-deps - if: steps.cache-deps.outputs.cache-hit == 'true' - run: | - sudo mkdir -p /opt - sudo mkdir -p /opt/QGIS - sudo cp -r ${DEPS_CACHE_DIR}/QGIS/qgis-deps-${QGIS_DEPS_VERSION}.${QGIS_DEPS_PATCH_VERSION} /opt/QGIS/qgis-deps-${QGIS_DEPS_VERSION} - - - name: Download qgis-deps - if: steps.cache-deps.outputs.cache-hit != 'true' - run: | - wget https://qgis.org/downloads/macos/deps/qgis-deps-${QGIS_DEPS_VERSION}.${QGIS_DEPS_PATCH_VERSION}.tar.gz - mkdir -p ${DEPS_CACHE_DIR} - mkdir -p ${DEPS_CACHE_DIR}/QGIS - - - name: Install Qt and deps - env: - QT_ALREADY_CACHED: ${{ steps.cache-qt.outputs.cache-hit }} - QGIS_DEPS_ALREADY_CACHED: ${{ steps.cache-deps.outputs.cache-hit }} - run: | - wget https://qgis.org/downloads/macos/deps/install_qgis_deps-${QGIS_DEPS_VERSION}.${QGIS_DEPS_PATCH_VERSION}.bash - chmod +x ./install_qgis_deps-${QGIS_DEPS_VERSION}.${QGIS_DEPS_PATCH_VERSION}.bash - echo ::group::Install deps - sudo ./install_qgis_deps-${QGIS_DEPS_VERSION}.${QGIS_DEPS_PATCH_VERSION}.bash - echo ::endgroup:: - [[ ${QT_ALREADY_CACHED} != "true" ]] && cp -r /opt/Qt/${QT_VERSION} ${DEPS_CACHE_DIR}/Qt/${QT_VERSION} || true - [[ ${QGIS_DEPS_ALREADY_CACHED} != "true" ]] && cp -r /opt/QGIS/qgis-deps-${QGIS_DEPS_VERSION} ${DEPS_CACHE_DIR}/QGIS/qgis-deps-${QGIS_DEPS_VERSION}.${QGIS_DEPS_PATCH_VERSION} || true - - - name: Install ccache - run: | - mkdir -p ${CCACHE_DIR} - brew install ccache - ccache --set-config=max_size=2.0G - ccache -s - - - name: Run cmake - run: | - mkdir -p ${BUILD_DIR} - cd ${BUILD_DIR} - - PATH=/opt/QGIS/qgis-deps-${QGIS_DEPS_VERSION}/stage/bin:$PATH \ - cmake -DQGIS_MAC_DEPS_DIR=/opt/QGIS/qgis-deps-${QGIS_DEPS_VERSION}/stage \ - -DCMAKE_PREFIX_PATH=/opt/Qt/${QT_VERSION}/clang_64 \ - -DWITH_BINDINGS=TRUE \ - -DWITH_3D=TRUE \ - -DWITH_DRACO=FALSE \ - -DWITH_PDAL=TRUE \ - -DWITH_EPT=TRUE \ - ../QGIS - - - name: Build QGIS - run: | - cd ${BUILD_DIR} - make -j $(sysctl -n hw.ncpu) - - - name: Save build cache for push only - uses: actions/cache/save@v4 - if: ${{ github.event_name == 'push' }} - with: - path: ${{ env.CCACHE_DIR }} - key: build-ccache-mac-${{ github.ref_name }}-${{ github.run_id }} diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index dcf2ee0d9d32..0e1c711f3857 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -58,21 +58,21 @@ jobs: # LD_PRELOAD: /lib/x86_64-linux-gnu/libSegFault.so experimental: false - - distro-version: '39' - qt-version: 6 - run-tests: true - with-qt6: ON - with-qt5: OFF - with-3d: ON - with-quick: ON - with-clazy: OFF - with-grass7: OFF - with-grass8: ON - with-webengine: ON - with-pdf4qt: ON - with-compile-commands: OFF - LD_PRELOAD: '' - experimental: false + # - distro-version: '39' + # qt-version: 6 + # run-tests: true + # with-qt6: ON + # with-qt5: OFF + # with-3d: ON + # with-quick: ON + # with-clazy: OFF + # with-grass7: OFF + # with-grass8: ON + # with-webengine: ON + # with-pdf4qt: ON + # with-compile-commands: OFF + # LD_PRELOAD: '' + # experimental: false fail-fast: false @@ -227,222 +227,222 @@ jobs: # set -e # switch back # docker stop qgis-testing-environment - run-tests: - name: Run tests - env: - QGIS_WORKSPACE: ${{ github.workspace }} # used in docker compose - - runs-on: ubuntu-latest - - needs: build - if: always() - - strategy: - matrix: - qt-version: [5, 6] - test-batch: [ALL_BUT_PROVIDERS, POSTGRES, HANA] - - include: - - qt-version: 5 - distro-version: 22.04 - docker-target: binary-only - - - qt-version: 6 - distro-version: 39 - docker-target: binary-only - - - qt-version: 5 - distro-version: 22.04 - test-batch: ORACLE - docker-target: binary-for-oracle - - exclude: - - qt-version: 6 - test-batch: HANA - - - qt-version: 6 - test-batch: POSTGRES - - fail-fast: false - - steps: - - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - tool-cache: true - large-packages: false - docker-images: false - swap-storage: true - - - name: Checkout - uses: actions/checkout@v4 - - - name: Set vars - env: - GITHUB_EVENT_NAME: ${{ github.event_name }} - GITHUB_REF: ${{ github.ref }} - GITHUB_PR_NUMBER: ${{github.event.number}} - run: | - # Be aware that these instructions are duplicated in build job - CTEST_BUILD_NAME=$( [[ ${GITHUB_EVENT_NAME} == pull_request ]] && echo "PR${GITHUB_PR_NUMBER}" || echo ${GITHUB_REF##*/} )"_${GITHUB_SHA}_${{ matrix.test-batch }}" - echo "CTEST_BUILD_NAME=${CTEST_BUILD_NAME}" >> $GITHUB_ENV - echo "QT_VERSION=${{ matrix.qt-version }}" >> $GITHUB_ENV - - - name: Print vars - run: | - echo CTEST_BUILD_NAME: ${CTEST_BUILD_NAME} - - - name: Login to Docker Hub - if: ${{ github.event_name == 'push' && github.actor == 'qgis' }} - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Build Docker Container with Testing Environment - id: docker-build - uses: docker/build-push-action@v6 - with: - context: . - file: .docker/qgis3-qt${{ matrix.qt-version }}-build-deps.dockerfile - tags: qgis/qgis3-qt${{ matrix.qt-version }}-build-deps-bin-only:${{ github.event.pull_request.base.ref || github.ref_name }} - push: ${{ github.event_name == 'push' && github.actor == 'qgis' }} - pull: true - target: ${{ matrix.docker-target }} - build-args: - DISTRO_VERSION=${{ matrix.distro-version }} - - - name: Tag image - run: docker tag ${{ steps.docker-build.outputs.imageid }} qgis3-build-deps-binary-image - - - name: Print disk space - run: | - echo "DOCKER IMAGES" - docker images - echo "DF -H" - sudo df -h - - - name: Download build artifact - uses: actions/download-artifact@v4 - with: - name: build-${{ matrix.distro-version }}-qt${{ matrix.qt-version }}.tgz - path: . - - - name: Extract build artifact - run: | - tar xvzf build.tgz - rm -Rf build.tgz - - - name: Print disk space - run: | - echo "DF -H" - sudo df -h - - - name: Run tests - id: tests - env: - TEST_BATCH: ${{matrix.test-batch}} - QGIS_COMMON_GIT_DIR: ${{ github.workspace }} - GITHUB_SHA: ${{ github.sha }} - run: | - DOCKERFILE=$( ( [[ ${{ matrix.test-batch }} == "ORACLE" ]] && echo "docker-compose-testing-oracle.yml" ) \ - || ( [[ ${{ matrix.test-batch }} == "POSTGRES" ]] && echo "docker-compose-testing-postgres.yml" ) \ - || echo "docker-compose-testing.yml" ) - [[ ${{ matrix.test-batch }} == "ORACLE" ]] && sudo rm -rf /usr/share/dotnet/sdk - echo "TEST_BATCH=$TEST_BATCH" - echo "DOCKERFILE=$DOCKERFILE" - mkdir -p /tmp/webdav_tests && chmod 777 /tmp/webdav_tests - mkdir -p /tmp/minio_tests/test-bucket && chmod -R 777 /tmp/minio_tests - docker compose -f .docker/$DOCKERFILE run -e GITHUB_SHA=$GITHUB_SHA qgis-deps /root/QGIS/.docker/docker-qgis-test.sh $TEST_BATCH - - - name: Fix permissions on test report - if: ${{ failure() }} - run: | - sudo chmod -R 777 qgis_test_report - - - name: Dump report contents - if: ${{ failure() }} - run: | - MD_REPORT_FILE="qgis_test_report/summary.md"; [ -f "$MD_REPORT_FILE" ] && cat "$MD_REPORT_FILE" || true - - - name: Save PR number to test report - if: ${{ failure() }} - run: | - echo ${{ github.event.number }} | tee qgis_test_report/pr_number - echo ${{ github.event.pull_request.head.sha }} | tee qgis_test_report/git_commit - - - name: Archive test results report - if: ${{ failure() }} - uses: actions/upload-artifact@v4 - with: - name: test-results-qt${{ matrix.qt-version }} - path: qgis_test_report - - clang-tidy: - if: github.event_name == 'pull_request' - runs-on: ubuntu-latest - needs: build - - strategy: - matrix: - include: - - distro-version: '22.04' - qt-version: 5 - - steps: - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - tool-cache: true - large-packages: false - docker-images: false - swap-storage: true - - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 2 - - - name: Login to Docker Hub - if: ${{ github.event_name == 'push' && github.actor == 'qgis' }} - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Build Docker Container with Testing Environment - id: docker-build - uses: docker/build-push-action@v6 - with: - context: . - file: .docker/qgis3-qt${{ matrix.qt-version }}-build-deps.dockerfile - tags: qgis/qgis3-qt${{ matrix.qt-version }}-build-deps-bin-only:${{ github.event.pull_request.base.ref || github.ref_name }} - push: ${{ github.event_name == 'push' && github.actor == 'qgis' }} - pull: true - target: ${{ matrix.docker-target }} - build-args: - DISTRO_VERSION=${{ matrix.distro-version }} - - - name: Tag image - run: docker tag ${{ steps.docker-build.outputs.imageid }} qgis3-build-deps-binary-image - - - name: Download build artifact - uses: actions/download-artifact@v4 - with: - name: build-${{ matrix.distro-version }}-qt${{ matrix.qt-version }}.tgz - path: . - - - name: Extract build artifact - run: | - tar xvzf build.tgz - rm -Rf build.tgz - - - name: Run Clang-Tidy - run: | - docker run -t --name qgis_container \ - -v $(pwd):/root/QGIS \ - -v /home/runner/QGIS/.ccache:/root/.ccache \ - --env-file .docker/docker-variables.env \ - qgis3-build-deps-binary-image \ - /root/QGIS/.docker/docker-qgis-clangtidy.sh + # run-tests: + # name: Run tests + # env: + # QGIS_WORKSPACE: ${{ github.workspace }} # used in docker compose + + # runs-on: ubuntu-latest + + # needs: build + # if: always() + + # strategy: + # matrix: + # qt-version: [5, 6] + # test-batch: [ALL_BUT_PROVIDERS, POSTGRES, HANA] + + # include: + # - qt-version: 5 + # distro-version: 22.04 + # docker-target: binary-only + + # - qt-version: 6 + # distro-version: 39 + # docker-target: binary-only + + # - qt-version: 5 + # distro-version: 22.04 + # test-batch: ORACLE + # docker-target: binary-for-oracle + + # exclude: + # - qt-version: 6 + # test-batch: HANA + + # - qt-version: 6 + # test-batch: POSTGRES + + # fail-fast: false + + # steps: + + # - name: Free Disk Space (Ubuntu) + # uses: jlumbroso/free-disk-space@main + # with: + # tool-cache: true + # large-packages: false + # docker-images: false + # swap-storage: true + + # - name: Checkout + # uses: actions/checkout@v4 + + # - name: Set vars + # env: + # GITHUB_EVENT_NAME: ${{ github.event_name }} + # GITHUB_REF: ${{ github.ref }} + # GITHUB_PR_NUMBER: ${{github.event.number}} + # run: | + # # Be aware that these instructions are duplicated in build job + # CTEST_BUILD_NAME=$( [[ ${GITHUB_EVENT_NAME} == pull_request ]] && echo "PR${GITHUB_PR_NUMBER}" || echo ${GITHUB_REF##*/} )"_${GITHUB_SHA}_${{ matrix.test-batch }}" + # echo "CTEST_BUILD_NAME=${CTEST_BUILD_NAME}" >> $GITHUB_ENV + # echo "QT_VERSION=${{ matrix.qt-version }}" >> $GITHUB_ENV + + # - name: Print vars + # run: | + # echo CTEST_BUILD_NAME: ${CTEST_BUILD_NAME} + + # - name: Login to Docker Hub + # if: ${{ github.event_name == 'push' && github.actor == 'qgis' }} + # uses: docker/login-action@v3 + # with: + # username: ${{ secrets.DOCKER_USERNAME }} + # password: ${{ secrets.DOCKER_PASSWORD }} + + # - name: Build Docker Container with Testing Environment + # id: docker-build + # uses: docker/build-push-action@v6 + # with: + # context: . + # file: .docker/qgis3-qt${{ matrix.qt-version }}-build-deps.dockerfile + # tags: qgis/qgis3-qt${{ matrix.qt-version }}-build-deps-bin-only:${{ github.event.pull_request.base.ref || github.ref_name }} + # push: ${{ github.event_name == 'push' && github.actor == 'qgis' }} + # pull: true + # target: ${{ matrix.docker-target }} + # build-args: + # DISTRO_VERSION=${{ matrix.distro-version }} + + # - name: Tag image + # run: docker tag ${{ steps.docker-build.outputs.imageid }} qgis3-build-deps-binary-image + + # - name: Print disk space + # run: | + # echo "DOCKER IMAGES" + # docker images + # echo "DF -H" + # sudo df -h + + # - name: Download build artifact + # uses: actions/download-artifact@v4 + # with: + # name: build-${{ matrix.distro-version }}-qt${{ matrix.qt-version }}.tgz + # path: . + + # - name: Extract build artifact + # run: | + # tar xvzf build.tgz + # rm -Rf build.tgz + + # - name: Print disk space + # run: | + # echo "DF -H" + # sudo df -h + + # - name: Run tests + # id: tests + # env: + # TEST_BATCH: ${{matrix.test-batch}} + # QGIS_COMMON_GIT_DIR: ${{ github.workspace }} + # GITHUB_SHA: ${{ github.sha }} + # run: | + # DOCKERFILE=$( ( [[ ${{ matrix.test-batch }} == "ORACLE" ]] && echo "docker-compose-testing-oracle.yml" ) \ + # || ( [[ ${{ matrix.test-batch }} == "POSTGRES" ]] && echo "docker-compose-testing-postgres.yml" ) \ + # || echo "docker-compose-testing.yml" ) + # [[ ${{ matrix.test-batch }} == "ORACLE" ]] && sudo rm -rf /usr/share/dotnet/sdk + # echo "TEST_BATCH=$TEST_BATCH" + # echo "DOCKERFILE=$DOCKERFILE" + # mkdir -p /tmp/webdav_tests && chmod 777 /tmp/webdav_tests + # mkdir -p /tmp/minio_tests/test-bucket && chmod -R 777 /tmp/minio_tests + # docker compose -f .docker/$DOCKERFILE run -e GITHUB_SHA=$GITHUB_SHA qgis-deps /root/QGIS/.docker/docker-qgis-test.sh $TEST_BATCH + + # - name: Fix permissions on test report + # if: ${{ failure() }} + # run: | + # sudo chmod -R 777 qgis_test_report + + # - name: Dump report contents + # if: ${{ failure() }} + # run: | + # MD_REPORT_FILE="qgis_test_report/summary.md"; [ -f "$MD_REPORT_FILE" ] && cat "$MD_REPORT_FILE" || true + + # - name: Save PR number to test report + # if: ${{ failure() }} + # run: | + # echo ${{ github.event.number }} | tee qgis_test_report/pr_number + # echo ${{ github.event.pull_request.head.sha }} | tee qgis_test_report/git_commit + + # - name: Archive test results report + # if: ${{ failure() }} + # uses: actions/upload-artifact@v4 + # with: + # name: test-results-qt${{ matrix.qt-version }} + # path: qgis_test_report + + # clang-tidy: + # if: github.event_name == 'pull_request' + # runs-on: ubuntu-latest + # needs: build + + # strategy: + # matrix: + # include: + # - distro-version: '22.04' + # qt-version: 5 + + # steps: + # - name: Free Disk Space (Ubuntu) + # uses: jlumbroso/free-disk-space@main + # with: + # tool-cache: true + # large-packages: false + # docker-images: false + # swap-storage: true + + # - name: Checkout + # uses: actions/checkout@v4 + # with: + # fetch-depth: 2 + + # - name: Login to Docker Hub + # if: ${{ github.event_name == 'push' && github.actor == 'qgis' }} + # uses: docker/login-action@v3 + # with: + # username: ${{ secrets.DOCKER_USERNAME }} + # password: ${{ secrets.DOCKER_PASSWORD }} + + # - name: Build Docker Container with Testing Environment + # id: docker-build + # uses: docker/build-push-action@v6 + # with: + # context: . + # file: .docker/qgis3-qt${{ matrix.qt-version }}-build-deps.dockerfile + # tags: qgis/qgis3-qt${{ matrix.qt-version }}-build-deps-bin-only:${{ github.event.pull_request.base.ref || github.ref_name }} + # push: ${{ github.event_name == 'push' && github.actor == 'qgis' }} + # pull: true + # target: ${{ matrix.docker-target }} + # build-args: + # DISTRO_VERSION=${{ matrix.distro-version }} + + # - name: Tag image + # run: docker tag ${{ steps.docker-build.outputs.imageid }} qgis3-build-deps-binary-image + + # - name: Download build artifact + # uses: actions/download-artifact@v4 + # with: + # name: build-${{ matrix.distro-version }}-qt${{ matrix.qt-version }}.tgz + # path: . + + # - name: Extract build artifact + # run: | + # tar xvzf build.tgz + # rm -Rf build.tgz + + # - name: Run Clang-Tidy + # run: | + # docker run -t --name qgis_container \ + # -v $(pwd):/root/QGIS \ + # -v /home/runner/QGIS/.ccache:/root/.ccache \ + # --env-file .docker/docker-variables.env \ + # qgis3-build-deps-binary-image \ + # /root/QGIS/.docker/docker-qgis-clangtidy.sh diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml deleted file mode 100644 index 735340239da2..000000000000 --- a/.github/workflows/windows-qt6.yml +++ /dev/null @@ -1,138 +0,0 @@ ---- -name: πŸͺŸ Windows Qt6 -on: - push: - branches: - - master - - release-** - pull_request: - release: - types: ['published'] - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - packages: write - -jobs: - build: - name: build (windows) - runs-on: windows-2022 - - steps: - - name: 🐣 Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 2 - - - name: 🐩 Install CMake and Ninja - uses: lukka/get-cmake@latest - with: - cmakeVersion: 3.29.6 - - - name: 🧽 Developer Command Prompt for Microsoft Visual C++ - uses: ilammy/msvc-dev-cmd@v1 - - - name: 🎑 Setup vcpkg - uses: ./.github/actions/setup-vcpkg - - - name: 🦬 Setup flex/bison - uses: robinraju/release-downloader@v1.11 - with: - repository: 'lexxmark/winflexbison' - fileName: '*.zip' - tag: 'v2.5.24' - extract: true - - - name: πŸ›οΈ Setup ccache - uses: hendrikmuhs/ccache-action@v1.2 - with: - max-size: 1G - key: build-ccache-win64-qt6-${{Β github.event.pull_request.base.ref || github.ref_name }} - save: ${{ github.event_name == 'push' }} - - - name: 🌱 Install dependencies and generate project files - shell: bash - run: | - BUILD_DIR=$( cygpath "${{ github.workspace }}/build" ) - SOURCE_DIR=$( cygpath "${{ github.workspace }}" ) - - cmake -S "${SOURCE_DIR}" \ - -B "${BUILD_DIR}" \ - -G Ninja \ - -D CMAKE_BUILD_TYPE=Release \ - -D WITH_VCPKG=ON \ - -D CREATE_ZIP=ON \ - -D VCPKG_TARGET_TRIPLET=x64-windows-release \ - -D VCPKG_HOST_TRIPLET=x64-windows-release \ - -D WITH_DESKTOP=ON \ - -D WITH_3D=ON \ - -D WITH_BINDINGS=ON \ - -D ENABLE_TESTS=OFF \ - -D BUILD_WITH_QT6=ON \ - -D USE_CCACHE=ON \ - -D FLEX_EXECUTABLE="${SOURCE_DIR}/win_flex.exe" \ - -D BISON_EXECUTABLE="${SOURCE_DIR}/win_bison.exe" \ - -D SIP_BUILD_EXECUTABLE="${BUILD_DIR}\vcpkg_installed\x64-windows-release\tools\python3\Scripts\sip-build.exe" \ - -D CMAKE_C_COMPILER_LAUNCHER=ccache \ - -D CMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -D WITH_QTWEBKIT=OFF \ - -D VCPKG_INSTALL_OPTIONS="--x-buildtrees-root=C:/src" \ - -D NUGET_USERNAME=${{ github.actor }} \ - -D NUGET_TOKEN=${{ secrets.GITHUB_TOKEN }} - - - name: πŸŒ‹ Build - shell: bash - run: | - cmake --build "${{ github.workspace }}/build" --config Release - -# - uses: m-kuhn/action-tmate@patch-1 -# if: failure() - - - name: πŸ“¦ Package - shell: bash - run: | - cmake --build "${{ github.workspace }}/build" --target bundle --config Release - - - name: πŸ“¦ Create SDK -# if: github.event_name == 'workflow_dispatch' || github.event_name == 'release' - run: | - vcpkg.exe export --zip --output-dir=./sdk --x-install-root=./build/vcpkg_installed --x-manifest-root=vcpkg - - - name: πŸ“€ Upload sdk -# if: github.event_name == 'workflow_dispatch' || github.event_name == 'release' - uses: actions/upload-artifact@v4 - with: - name: qgis-sdk-x64-windows - path: | - sdk/vcpkg-export-*.zip - - - name: πŸ“‘ Upload dep build logs - uses: actions/upload-artifact@v4 - if: failure() - with: - name: build-logs-x64-windows - path: | - C:/src/**/*.log - - - name: πŸ“€ Upload bundle - uses: actions/upload-artifact@v4 - id: artifact-win64-qt6 - with: - name: qgis-windows-qt6 - path: | - build/*-win64.zip - - - - name: Schedule download comment - uses: ./.github/actions/post_sticky_comment - if: github.event_name == 'pull_request' - with: - marker: mingw64-qt6 - body: | - ### πŸͺŸ Windows Qt6 builds - Download [Windows Qt6 builds of this PR for testing](${{ steps.artifact-win64-qt6.outputs.artifact-url }}). - *(Built from commit ${{ github.event.pull_request.head.sha }})* - pr: ${{ github.event.number }} From 76e27d7bc45f13ecd09c907e4971e0e299615945 Mon Sep 17 00:00:00 2001 From: bdm-oslandia Date: Fri, 29 Nov 2024 12:05:48 +0100 Subject: [PATCH 08/15] debug ogc test3 --- .github/workflows/mingw64.yml | 130 ---------------------------------- 1 file changed, 130 deletions(-) delete mode 100644 .github/workflows/mingw64.yml diff --git a/.github/workflows/mingw64.yml b/.github/workflows/mingw64.yml deleted file mode 100644 index 9a08654fc933..000000000000 --- a/.github/workflows/mingw64.yml +++ /dev/null @@ -1,130 +0,0 @@ -name: πŸͺŸ MingW64 Windows 64bit Build - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -on: - push: - branches: - - master - - release-** - - queued_ltr_backports - paths: - - 'src/**' - - 'external/**' - - 'python/**' - - 'tests/**' - - 'ms-windows/**' - - 'CMakeLists.txt' - - '.github/workflows/mingw64.yml' - pull_request: - workflow_dispatch: - -permissions: - contents: read - -jobs: - mingw64-build: - name: MinGW64 Windows Build - runs-on: ubuntu-latest - container: - image: fedora:39 - options: --security-opt seccomp=unconfined - volumes: - - ${{ github.workspace }}:/w - steps: - - - uses: actions/checkout@v4 - - # To be removed - # Workaround a bug where the initial /etc/dnf/dnf.conf file contains - # just the "tsflags=nodocs" line - - name: Replace broken dnf.conf - run: printf '[main]\ngpgcheck=True\ninstallonly_limit=3\nclean_requirements_on_remove=True\nbest=False\nskip_if_unavailable=True\ntsflags=nodocs' > /etc/dnf/dnf.conf - - - name: Update system - run: dnf -y update - - - name: Install core dependencies - run: dnf -y install zip - - - name: Install build dependencies - run: ./ms-windows/mingw/mingwdeps.sh - - # Node.js and Yarn for server landingpage webapp - - uses: actions/setup-node@v4 - with: - node-version: '17' - - - name: Make yarn available - run: corepack enable - - - name: Create ccache dir - run: mkdir -p /w/.ccache/QGIS - - - name: Restore build cache - uses: actions/cache/restore@v4 - with: - path: /w/.ccache/QGIS - key: build-ccache-mingw64-${{Β github.event.pull_request.base.ref || github.ref_name }} - restore-keys: | - build-ccache-mingw64-master - - - name: Build QGIS Application - run: CCACHE_DIR=/w/.ccache/QGIS ./ms-windows/mingw/build.sh x86_64 nodebug 4 - - - name: Save build cache for push only - uses: actions/cache/save@v4 - if: ${{ github.event_name == 'push' }} - with: - path: /w/.ccache/QGIS - key: build-ccache-mingw64-${{ github.ref_name }}-${{ github.run_id }} - - - name: Create Portable zip - run: | - DISTROOT=build_mingw64/dist/usr/x86_64-w64-mingw32/sys-root/mingw - DEBUGROOT=dist_debug - for file in $(find $DISTROOT -name '*.debug' \( -type l -or -type f \)); do - DEST=${file/$DISTROOT/$DEBUGROOT} - mkdir -p "$(dirname $DEST)" - sudo mv "$file" "$DEST" - done - sudo mv $DISTROOT QGIS-Portable - zip -r qgis-portable-win64.zip QGIS-Portable - (cd $DEBUGROOT && zip -r - *) > qgis-portable-win64-debugsym.zip - - - name: Save PR number to zips - run: | - echo ${{ github.event.number }} | tee pr_number - zip -u qgis-portable-win64.zip pr_number - zip -u qgis-portable-win64-debugsym.zip pr_number - echo ${{ github.event.pull_request.head.sha }} | tee git_commit - zip -u qgis-portable-win64.zip git_commit - zip -u qgis-portable-win64-debugsym.zip git_commit - - - name: Upload QGIS for Windows 64bit - uses: actions/upload-artifact@v4 - id: artifact-win64 - with: - name: QGIS for Windows 64bit - path: qgis-portable-win64.zip - - - name: Upload QGIS for Windows 64bit Debug Symbols - uses: actions/upload-artifact@v4 - id: artifact-win64-debug - with: - name: QGIS for Windows 64bit Debug Symbols - path: qgis-portable-win64-debugsym.zip - - - name: Schedule download comment - uses: ./.github/actions/post_sticky_comment - if: github.event_name == 'pull_request' - with: - marker: mingw64 - body: | - ### πŸͺŸ Windows builds - Download [Windows builds of this PR for testing](${{ steps.artifact-win64.outputs.artifact-url }}). - Debug symbols for this build are available [here](${{ steps.artifact-win64-debug.outputs.artifact-url }}). - *(Built from commit ${{ github.event.pull_request.head.sha }})* - pr: ${{ github.event.number }} From 762d7568543952a076c1f42aa5cddbf31e1ca088 Mon Sep 17 00:00:00 2001 From: bdm-oslandia Date: Fri, 29 Nov 2024 14:41:46 +0100 Subject: [PATCH 09/15] build against my repo --- .ci/ogc/build.sh | 2 +- .github/workflows/ogc.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.ci/ogc/build.sh b/.ci/ogc/build.sh index 55787a7e3768..63cae69f85ac 100755 --- a/.ci/ogc/build.sh +++ b/.ci/ogc/build.sh @@ -2,7 +2,7 @@ set -e -mkdir /usr/src/qgis/build +mkdir -p /usr/src/qgis/build cd /usr/src/qgis/build || exit 1 export CCACHE_TEMPDIR=/tmp diff --git a/.github/workflows/ogc.yml b/.github/workflows/ogc.yml index b2e4cef44076..6ab11f7daac5 100644 --- a/.github/workflows/ogc.yml +++ b/.github/workflows/ogc.yml @@ -81,8 +81,8 @@ jobs: - name: Install pyogctest run: | sudo apt-get update && sudo apt-get install python3-virtualenv virtualenv git - git clone https://github.com/pblottiere/pyogctest - cd pyogctest && git checkout 1.1.1 && cd - + git clone https://github.com/benoitdm-oslandia/pyogctest + cd pyogctest && git checkout fix/docker_ulimit && cd - virtualenv -p /usr/bin/python3 venv && source venv/bin/activate && pip install -e pyogctest/ - name: Run WMS 1.3.0 OGC tests From 31f381dc76650098082624e12fac0ea9f7663d3a Mon Sep 17 00:00:00 2001 From: bdm-oslandia Date: Fri, 29 Nov 2024 15:02:30 +0100 Subject: [PATCH 10/15] activate qgis debug --- .ci/ogc/build.sh | 1 + .ci/ogc/docker-compose.yml | 3 +++ .github/workflows/ogc.yml | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.ci/ogc/build.sh b/.ci/ogc/build.sh index 63cae69f85ac..72dfef166906 100755 --- a/.ci/ogc/build.sh +++ b/.ci/ogc/build.sh @@ -14,6 +14,7 @@ ccache -M 2.0G ccache -z cmake -GNinja \ + -DCMAKE_BUILD_TYPE=Debug \ -DUSE_CCACHE=ON \ -DWITH_QUICK=OFF \ -DWITH_3D=OFF \ diff --git a/.ci/ogc/docker-compose.yml b/.ci/ogc/docker-compose.yml index 145d8e4162e3..6021c021277c 100644 --- a/.ci/ogc/docker-compose.yml +++ b/.ci/ogc/docker-compose.yml @@ -23,6 +23,9 @@ services: networks: - qgis privileged: true + environment: + QGIS_DEBUG: 4 + networks: qgis: diff --git a/.github/workflows/ogc.yml b/.github/workflows/ogc.yml index 6ab11f7daac5..458ccaa27fa8 100644 --- a/.github/workflows/ogc.yml +++ b/.github/workflows/ogc.yml @@ -88,7 +88,7 @@ jobs: - name: Run WMS 1.3.0 OGC tests run: | source venv/bin/activate && ./pyogctest/pyogctest.py -s wms130 -e - docker compose -f .ci/ogc/docker-compose.yml up -d + docker compose -f .ci/ogc/docker-compose.yml up & source venv/bin/activate && ./pyogctest/pyogctest.py -n ogc_qgis -s wms130 -d -v -u http://$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' qgis_server_nginx)/qgisserver_wms130 env: DOCKER_IMAGE: ${{ steps.docker-build.outputs.imageid }} From 98cf442e037a5ade473dfed884a2c224708cec50 Mon Sep 17 00:00:00 2001 From: bdm-oslandia Date: Fri, 29 Nov 2024 16:16:13 +0100 Subject: [PATCH 11/15] activate qgis debug 2 --- .github/workflows/ogc.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ogc.yml b/.github/workflows/ogc.yml index 458ccaa27fa8..f5ce42e81592 100644 --- a/.github/workflows/ogc.yml +++ b/.github/workflows/ogc.yml @@ -88,7 +88,8 @@ jobs: - name: Run WMS 1.3.0 OGC tests run: | source venv/bin/activate && ./pyogctest/pyogctest.py -s wms130 -e - docker compose -f .ci/ogc/docker-compose.yml up & + docker compose -f .ci/ogc/docker-compose.yml up -d + docker compose -f .ci/ogc/docker-compose.yml logs -f & source venv/bin/activate && ./pyogctest/pyogctest.py -n ogc_qgis -s wms130 -d -v -u http://$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' qgis_server_nginx)/qgisserver_wms130 env: DOCKER_IMAGE: ${{ steps.docker-build.outputs.imageid }} From 83b5c034a5653d59c878d5eb0412c375d699a64b Mon Sep 17 00:00:00 2001 From: bdm-oslandia Date: Mon, 2 Dec 2024 09:07:19 +0100 Subject: [PATCH 12/15] more debug messages --- .ci/ogc/docker-compose.yml | 2 +- src/server/qgis_map_serv.cpp | 2 +- src/server/qgsfcgiserverresponse.cpp | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.ci/ogc/docker-compose.yml b/.ci/ogc/docker-compose.yml index 6021c021277c..d0f2a7c9cb3d 100644 --- a/.ci/ogc/docker-compose.yml +++ b/.ci/ogc/docker-compose.yml @@ -24,7 +24,7 @@ services: - qgis privileged: true environment: - QGIS_DEBUG: 4 + QGIS_DEBUG: 5 networks: diff --git a/src/server/qgis_map_serv.cpp b/src/server/qgis_map_serv.cpp index 931ec2642ad2..16ed3809c4bb 100644 --- a/src/server/qgis_map_serv.cpp +++ b/src/server/qgis_map_serv.cpp @@ -97,7 +97,7 @@ int main( int argc, char *argv[] ) response.sendError( 400, "Bad request" ); } } + QgsDebugMsgLevel( QStringLiteral( "FCGIServer: main quits." ), 2 ); QgsApplication::exitQgis(); return 0; } - diff --git a/src/server/qgsfcgiserverresponse.cpp b/src/server/qgsfcgiserverresponse.cpp index 0784dc9ea008..8b099c47edf9 100644 --- a/src/server/qgsfcgiserverresponse.cpp +++ b/src/server/qgsfcgiserverresponse.cpp @@ -159,6 +159,7 @@ QgsFcgiServerResponse::~QgsFcgiServerResponse() if ( mSocketMonitoringThread ) // This will allow the thread to finish sleeping and exit its while loop in the background, without us needing to wait for it to finish. mSocketMonitoringThread->setResponseFinished( mFinished ); + QgsDebugMsgLevel( QStringLiteral( "FCGIServer: response quits." ), 2 ); } void QgsFcgiServerResponse::removeHeader( const QString &key ) From c344443e2106ff938b81cfab49c4e275ead77293 Mon Sep 17 00:00:00 2001 From: bdm-oslandia Date: Mon, 2 Dec 2024 10:36:43 +0100 Subject: [PATCH 13/15] try with qpointer --- src/server/qgsfcgiserverresponse.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/qgsfcgiserverresponse.h b/src/server/qgsfcgiserverresponse.h index 92b4ece80b91..04fae0b4d115 100644 --- a/src/server/qgsfcgiserverresponse.h +++ b/src/server/qgsfcgiserverresponse.h @@ -122,7 +122,7 @@ class SERVER_EXPORT QgsFcgiServerResponse: public QgsServerResponse QgsServerRequest::Method mMethod; int mStatusCode = 0; - QgsSocketMonitoringThread *mSocketMonitoringThread; + QPointer mSocketMonitoringThread; std::shared_ptr mFeedback; }; From 2ccbdb855b625610c49d254da3323bbde4165d0e Mon Sep 17 00:00:00 2001 From: bdm-oslandia Date: Mon, 2 Dec 2024 11:41:08 +0100 Subject: [PATCH 14/15] fixup! try with qpointer --- src/server/qgsfcgiserverresponse.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/server/qgsfcgiserverresponse.h b/src/server/qgsfcgiserverresponse.h index 04fae0b4d115..5d569a027ecd 100644 --- a/src/server/qgsfcgiserverresponse.h +++ b/src/server/qgsfcgiserverresponse.h @@ -27,6 +27,7 @@ #include #include +#include /** * \ingroup server From 1ec44a0c3c1c389bb49107875cc803f5d8d053e2 Mon Sep 17 00:00:00 2001 From: bdm-oslandia Date: Mon, 2 Dec 2024 14:35:10 +0100 Subject: [PATCH 15/15] try shared_ptr + detach --- src/server/qgsfcgiserverresponse.cpp | 23 +++++++++++++---------- src/server/qgsfcgiserverresponse.h | 8 ++++---- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/server/qgsfcgiserverresponse.cpp b/src/server/qgsfcgiserverresponse.cpp index 8b099c47edf9..4bf1202a33c1 100644 --- a/src/server/qgsfcgiserverresponse.cpp +++ b/src/server/qgsfcgiserverresponse.cpp @@ -58,7 +58,6 @@ QgsSocketMonitoringThread::QgsSocketMonitoringThread( std::shared_ptr ptr ) +{ + mySelf = ptr; +} + void QgsSocketMonitoringThread::run( ) { if ( mIpcFd < 0 ) @@ -134,6 +134,7 @@ void QgsSocketMonitoringThread::run( ) QgsDebugMsgLevel( QStringLiteral( "FCGIServer: socket monitoring quits: no more socket." ), 2 ); } #endif + mySelf = nullptr; } @@ -149,16 +150,18 @@ QgsFcgiServerResponse::QgsFcgiServerResponse( QgsServerRequest::Method method ) setDefaultHeaders(); // This is not a unique_ptr because we want the response to not depend on the thread lifecycle. - mSocketMonitoringThread = new QgsSocketMonitoringThread( mFeedback ); - mSocketMonitoringThread->start(); + mSocketMonitoringThread = std::make_shared( mFeedback ); + mSocketMonitoringThread->setShared( mSocketMonitoringThread ); + std::thread mThread = std::thread( &QgsSocketMonitoringThread::run, mSocketMonitoringThread ); + mThread.detach(); } QgsFcgiServerResponse::~QgsFcgiServerResponse() { mFinished = true; - if ( mSocketMonitoringThread ) - // This will allow the thread to finish sleeping and exit its while loop in the background, without us needing to wait for it to finish. - mSocketMonitoringThread->setResponseFinished( mFinished ); + // if ( mSocketMonitoringThread ) + // This will allow the thread to finish sleeping and exit its while loop in the background, without us needing to wait for it to finish. + mSocketMonitoringThread->setResponseFinished( mFinished ); QgsDebugMsgLevel( QStringLiteral( "FCGIServer: response quits." ), 2 ); } diff --git a/src/server/qgsfcgiserverresponse.h b/src/server/qgsfcgiserverresponse.h index 5d569a027ecd..8badd5c51924 100644 --- a/src/server/qgsfcgiserverresponse.h +++ b/src/server/qgsfcgiserverresponse.h @@ -35,10 +35,8 @@ * \brief Thread used to monitor the fcgi socket * \since QGIS 3.36 */ -class QgsSocketMonitoringThread: public QThread +class QgsSocketMonitoringThread { - Q_OBJECT - public: /** @@ -50,11 +48,13 @@ class QgsSocketMonitoringThread: public QThread void run( ); void setResponseFinished( bool responseFinished ); + void setShared( std::shared_ptr ptr ); private: bool mIsResponseFinished = false; std::shared_ptr mFeedback; int mIpcFd = -1; + std::shared_ptr mySelf; }; /** @@ -123,7 +123,7 @@ class SERVER_EXPORT QgsFcgiServerResponse: public QgsServerResponse QgsServerRequest::Method mMethod; int mStatusCode = 0; - QPointer mSocketMonitoringThread; + std::shared_ptr mSocketMonitoringThread; std::shared_ptr mFeedback; };