From 944bc0116b42c9529af8149a7ca7e81b6c17690b Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 3 Oct 2024 01:06:54 +0100 Subject: [PATCH] fix: build errors --- .github/workflows/build.yml | 12 +++------- app/CMakeLists.txt | 19 +--------------- app/MainWindow.cpp | 5 ++++- app/ResourceHandle.cpp | 25 +++++++++------------ app/ResourceHandle.h | 19 ++++++++-------- app/catch2/CMakeLists.txt | 2 +- app/catch2/CalypAppTests.cpp | 2 +- app/catch2/CalypResourcesTests.cpp | 2 +- app/models/CalypResource.h | 11 +++++----- app/models/VideostreamResource.cpp | 35 +++++++++++++++--------------- app/models/VideostreamResource.h | 7 +++--- lib/CalypFrame.cpp | 6 ++--- 12 files changed, 60 insertions(+), 85 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 27f2141..29995c7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build on Linux +name: Build/Test Pipeline on: push: @@ -18,11 +18,8 @@ jobs: # well on Windows or Mac. You can convert this to a matrix build if you need # cross-platform coverage. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 name: Build (Linux) - env: - CC: gcc-13 - CXX: g++-13 steps: - name: Install dependencies run: sudo apt-get update && sudo apt-get install cmake qtbase5-dev libavcodec-dev libavformat-dev libavutil-dev libopencv-dev libopencv-video-dev libopencv-contrib-dev @@ -68,11 +65,8 @@ jobs: check-tests-linux: name: Tests (Linux) - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 needs: check-build-linux - env: - CC: gcc-13 - CXX: g++-13 steps: - name: Install dependencies run: sudo apt-get update && sudo apt-get install cmake qtbase5-dev qt6-base-dev libavcodec-dev libavformat-dev libavutil-dev libopencv-dev libopencv-video-dev libopencv-contrib-dev diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 773280f..4776076 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -197,22 +197,5 @@ INSTALL(FILES resources/calyp.png DESTINATION share/pixmaps) INSTALL(FILES resources/calyp.xml DESTINATION share/mime/packages) IF(BUILD_TESTS) - FETCHCONTENT_MAKEAVAILABLE(Catch2) - - SET(Calyp_App_Catch2_Tests_SRCS ${Calyp_App_Module_SRCS} catch2/CalypAppTests.cpp catch2/CalypResourcesTests.cpp) - - ADD_DEFINITIONS(-DCALYP_TEST_DATA_DIR=\"${CALYP_TEST_DATA_DIR}\") - - ADD_EXECUTABLE(CalypAppCatch2Tests ${Calyp_App_Catch2_Tests_SRCS}) - TARGET_LINK_LIBRARIES( - CalypAppCatch2Tests - ${PROJECT_LIBRARY} - CalypModules - ${APP_LINKER_LIBS} - ${QT_LINKER_LIBS} - QCustomPlotLib - Catch2::Catch2 - ) - CATCH_DISCOVER_TESTS(CalypAppCatch2Tests) - + ADD_SUBDIRECTORY(catch2) ENDIF() diff --git a/app/MainWindow.cpp b/app/MainWindow.cpp index e1def6f..a82d923 100644 --- a/app/MainWindow.cpp +++ b/app/MainWindow.cpp @@ -45,6 +45,7 @@ #include "VideoHandle.h" #include "VideoSubWindow.h" #include "lib/CalypOptions.h" +#include "models/VideostreamResource.h" #ifdef USE_FERVOR #include "fvupdater.h" #endif @@ -908,11 +909,13 @@ void MainWindow::addStreamInfoToRecentList( CalypFileInfo streamInfo ) if( idx >= 0 ) m_aRecentFileStreamInfo.remove( idx ); m_aRecentFileStreamInfo.prepend( streamInfo ); while( m_aRecentFileStreamInfo.size() > MAX_RECENT_FILES ) + { m_aRecentFileStreamInfo.remove( m_aRecentFileStreamInfo.size() - 1 ); + } updateRecentFileActions(); QSettings appSettings; QVariant var; - var.setValue( m_aRecentFileStreamInfo ); + var.setValue( m_aRecentFileStreamInfo ); appSettings.setValue( "MainWindow/RecentFileList", var ); } diff --git a/app/ResourceHandle.cpp b/app/ResourceHandle.cpp index 919313e..d1bee41 100644 --- a/app/ResourceHandle.cpp +++ b/app/ResourceHandle.cpp @@ -30,10 +30,7 @@ #include #include #include -#include -#include #include -#include auto get_new_resource_id() -> std::size_t { @@ -48,7 +45,9 @@ ResourceWorker::~ResourceWorker() void ResourceWorker::stop() { - while( m_bStarting ) {} + while( m_bStarting ) + { + } m_bStop = true; if( m_bStarted ) { @@ -158,8 +157,7 @@ auto ResourceHandle::getResource( CalypStream* ptr ) -> std::size_t { if( auto* resource = dynamic_cast( m_apcStreamResourcesList[i].get() ) ) { - if( &resource->m_stream == ptr ) - return i; + if( &resource->m_stream == ptr ) return i; } } } @@ -168,11 +166,8 @@ auto ResourceHandle::getResource( CalypStream* ptr ) -> std::size_t auto ResourceHandle::getResourceAsset( std::size_t id ) -> CalypStream* { - if( m_apcStreamResourcesWorkersList.count( id ) ) - { - return m_apcStreamResourcesList[id]->getResource(); - } - return nullptr; + if( !m_apcStreamResourcesWorkersList.contains( id ) ) return nullptr; + return m_apcStreamResourcesList[id]->getResource(); } auto ResourceHandle::appendResource( std::unique_ptr&& resource ) -> std::size_t @@ -186,7 +181,7 @@ auto ResourceHandle::appendResource( std::unique_ptr&& resource ) void ResourceHandle::removeResource( std::size_t id ) { - if( !m_apcStreamResourcesList.count( id ) ) + if( !m_apcStreamResourcesList.contains( id ) ) { assert( false ); return; @@ -202,7 +197,7 @@ void ResourceHandle::removeResource( std::size_t id ) void ResourceHandle::stopResourceWorker( std::size_t id ) { - if( !m_apcStreamResourcesWorkersList.count( id ) ) + if( !m_apcStreamResourcesWorkersList.contains( id ) ) { assert( false ); return; @@ -212,7 +207,7 @@ void ResourceHandle::stopResourceWorker( std::size_t id ) void ResourceHandle::startResourceWorker( std::size_t id ) { - if( !m_apcStreamResourcesWorkersList.count( id ) ) + if( !m_apcStreamResourcesWorkersList.contains( id ) ) { assert( false ); return; @@ -225,7 +220,7 @@ void ResourceHandle::startResourceWorker( std::size_t id ) void ResourceHandle::wakeResourceWorker( std::size_t id ) { - if( !m_apcStreamResourcesWorkersList.count( id ) ) + if( !m_apcStreamResourcesWorkersList.contains( id ) ) { assert( false ); return; diff --git a/app/ResourceHandle.h b/app/ResourceHandle.h index 33ef9d1..cbe4360 100644 --- a/app/ResourceHandle.h +++ b/app/ResourceHandle.h @@ -33,7 +33,6 @@ #include #include "CalypResource.h" -#include "CommonDefs.h" #include "lib/CalypStream.h" class ResourceWorker : public QThread @@ -47,12 +46,12 @@ private: std::atomic m_bStarting{ false }; public: - ResourceWorker( std::shared_ptr resource ) : m_resource{ std::move( resource ) } {} + explicit ResourceWorker( std::shared_ptr resource ) : m_resource{ std::move( resource ) } {} ResourceWorker( ResourceWorker&& other ) noexcept = delete; - ResourceWorker& operator=( ResourceWorker&& other ) noexcept = delete; ResourceWorker( const ResourceWorker& other ) = delete; - ResourceWorker& operator=( const ResourceWorker& other ) = delete; - ~ResourceWorker(); + auto operator=( ResourceWorker&& other ) noexcept -> ResourceWorker& = delete; + auto operator=( const ResourceWorker& other ) -> ResourceWorker& = delete; + ~ResourceWorker() override; void stop(); void wake(); void start(); @@ -68,10 +67,10 @@ class ResourceHandle : public QObject public: ResourceHandle(); ResourceHandle( ResourceHandle&& other ) noexcept = delete; - ResourceHandle& operator=( ResourceHandle&& other ) noexcept = delete; ResourceHandle( const ResourceHandle& other ) = delete; - ResourceHandle& operator=( const ResourceHandle& other ) = delete; - ~ResourceHandle(); + auto operator=( ResourceHandle&& other ) noexcept -> ResourceHandle& = delete; + auto operator=( const ResourceHandle& other ) -> ResourceHandle& = delete; + ~ResourceHandle() override; auto getResource( CalypStream* ptr ) -> std::size_t; auto getResourceAsset( std::size_t id ) -> CalypStream*; @@ -86,7 +85,7 @@ public: auto executeResourceAction( std::size_t id, const std::function& action ) -> bool { static_assert( std::is_base_of::value, "T must inherit from CalypResource" ); - if( !m_apcStreamResourcesList.count( id ) ) + if( !m_apcStreamResourcesList.contains( id ) ) { assert( false ); return false; @@ -106,7 +105,7 @@ public: private: auto addResource() -> std::size_t; -private: +private: // NOLINT std::unique_ptr m_thread; std::map> m_apcStreamResourcesList; std::map> m_apcStreamResourcesWorkersList; diff --git a/app/catch2/CMakeLists.txt b/app/catch2/CMakeLists.txt index a79c31c..e5bacc6 100644 --- a/app/catch2/CMakeLists.txt +++ b/app/catch2/CMakeLists.txt @@ -16,6 +16,6 @@ TARGET_LINK_LIBRARIES( ${APP_LINKER_LIBS} ${QT_LINKER_LIBS} QCustomPlotLib - Catch2::Catch2 + Catch2::Catch2WithMain ) CATCH_DISCOVER_TESTS(CalypAppCatch2Tests) diff --git a/app/catch2/CalypAppTests.cpp b/app/catch2/CalypAppTests.cpp index 7bff40f..2893178 100644 --- a/app/catch2/CalypAppTests.cpp +++ b/app/catch2/CalypAppTests.cpp @@ -23,4 +23,4 @@ */ #define CATCH_CONFIG_MAIN -#include +#include diff --git a/app/catch2/CalypResourcesTests.cpp b/app/catch2/CalypResourcesTests.cpp index b34f52a..96f46fb 100644 --- a/app/catch2/CalypResourcesTests.cpp +++ b/app/catch2/CalypResourcesTests.cpp @@ -23,7 +23,7 @@ */ #include -#include +#include #include #include #include diff --git a/app/models/CalypResource.h b/app/models/CalypResource.h index 3e739f0..77d1c50 100644 --- a/app/models/CalypResource.h +++ b/app/models/CalypResource.h @@ -38,14 +38,15 @@ public: virtual auto isReady() -> bool = 0; virtual auto getResourceName() -> std::string = 0; - [[deprecated( "Do not directly access the resource" )]] virtual auto getResource() -> CalypStream* = 0; + // TODO(JC) [[deprecated( "Do not directly access the resource" )]] after refactoring + virtual auto getResource() -> CalypStream* = 0; protected: CalypResource() = default; - CalypResource( CalypResource&& other ) noexcept = delete; - CalypResource& operator=( CalypResource&& other ) noexcept = delete; - CalypResource( const CalypResource& other ) = delete; - CalypResource& operator=( const CalypResource& other ) = delete; + CalypResource( CalypResource&& other ) noexcept = default; + CalypResource( const CalypResource& other ) = default; + auto operator=( CalypResource&& other ) noexcept -> CalypResource& = default; + auto operator=( const CalypResource& other ) -> CalypResource& = default; }; #endif // __CALYPRESOURCE_H__ diff --git a/app/models/VideostreamResource.cpp b/app/models/VideostreamResource.cpp index 7e0b392..8d78d18 100644 --- a/app/models/VideostreamResource.cpp +++ b/app/models/VideostreamResource.cpp @@ -38,27 +38,25 @@ * \brief Functions to control data stream from stream information */ -QDataStream& operator<<( QDataStream& out, const CalypFileInfoVector& array ) +auto operator<<( QDataStream& out, const CalypFileInfoVector& infos ) -> QDataStream& { - CalypFileInfo d; - out << array.size(); - for( int i = 0; i < array.size(); i++ ) + out << infos.size(); + for( const auto& info : infos ) { - d = array.at( i ); - out << d.m_cFilename << d.m_uiWidth << d.m_uiHeight << static_cast( d.m_iPelFormat ) << d.m_uiBitsPelPixel - << d.m_iEndianness << d.m_uiFrameRate << d.m_uiFileSize << d.m_bForceRaw; + out << info.m_cFilename << info.m_uiWidth << info.m_uiHeight << static_cast( info.m_iPelFormat ) + << info.m_uiBitsPelPixel << info.m_iEndianness << info.m_uiFrameRate << info.m_uiFileSize << info.m_bForceRaw; } return out; } -QDataStream& operator>>( QDataStream& in, CalypFileInfoVector& array ) +auto operator>>( QDataStream& in, CalypFileInfoVector& infos ) -> QDataStream& { - int array_size{ 0 }; + auto array_size = infos.size(); in >> array_size; for( int i = 0; i < array_size; i++ ) { CalypFileInfo d; - int pelFormat; + int pelFormat{ 0 }; in >> d.m_cFilename; in >> d.m_uiWidth; in >> d.m_uiHeight; @@ -69,7 +67,7 @@ QDataStream& operator>>( QDataStream& in, CalypFileInfoVector& array ) in >> d.m_uiFileSize; in >> d.m_bForceRaw; d.m_iPelFormat = static_cast( pelFormat ); - array.append( d ); + infos.append( d ); } return in; } @@ -77,8 +75,9 @@ QDataStream& operator>>( QDataStream& in, CalypFileInfoVector& array ) auto findCalypStreamInfo( const CalypFileInfoVector& array, const QString& filename ) -> int { for( int i = 0; i < array.size(); i++ ) - if( array.at( i ).m_cFilename == filename ) - return i; + { + if( array.at( i ).m_cFilename == filename ) return i; + } return -1; } @@ -160,8 +159,7 @@ void VideostreamResource::pause() void VideostreamResource::seekAbsoluteEvent( unsigned int new_frame_num ) { - if( m_currStream.seekInput( new_frame_num ) ) - triggerRefresh(); + if( m_currStream.seekInput( new_frame_num ) ) triggerRefresh(); } void VideostreamResource::seekRelativeEvent( bool bIsForward ) @@ -186,7 +184,9 @@ void VideostreamResource::stop() auto VideostreamResource::goToNextFrame( bool bThreaded ) -> bool { - while( !m_currStream.hasNextFrame() && !m_currStream.isEof() ) {} + while( !m_currStream.hasNextFrame() && !m_currStream.isEof() ) + { + } bool bEndOfSeq = m_currStream.setNextFrame(); if( !bEndOfSeq ) { @@ -345,8 +345,7 @@ auto video_resource_guess_format( const QString& filename, unsigned int& rWidth, rEndianness = CLP_LITTLE_ENDIAN; } - if( rWidth > 0 && rHeight > 0 && rInputFormat != ClpPixelFormats::Invalid ) - bGuessed = true && !bGuessedByFilesize; + if( rWidth > 0 && rHeight > 0 && rInputFormat != ClpPixelFormats::Invalid ) bGuessed = true && !bGuessedByFilesize; } return bGuessed; } \ No newline at end of file diff --git a/app/models/VideostreamResource.h b/app/models/VideostreamResource.h index def1440..4347f76 100644 --- a/app/models/VideostreamResource.h +++ b/app/models/VideostreamResource.h @@ -45,10 +45,11 @@ struct CalypFileInfo unsigned long long int m_uiFileSize; bool m_bForceRaw{ false }; }; + using CalypFileInfoVector = QVector; -QDataStream& operator<<( QDataStream& out, const CalypFileInfoVector& d ); -QDataStream& operator>>( QDataStream& in, CalypFileInfoVector& d ); +auto operator<<( QDataStream& out, const CalypFileInfoVector& infos ) -> QDataStream&; +auto operator>>( QDataStream& in, CalypFileInfoVector& infos ) -> QDataStream&; auto findCalypStreamInfo( const CalypFileInfoVector& array, const QString& filename ) -> int; class VideostreamResource : public QObject, public CalypResource @@ -88,7 +89,7 @@ private: // Q_SIGNALS: // private Q_SLOTS: -private: +private: // NOLINT CalypStream m_currStream; CalypFileInfo m_sStreamInfo; diff --git a/lib/CalypFrame.cpp b/lib/CalypFrame.cpp index a22aacb..b89c1df 100644 --- a/lib/CalypFrame.cpp +++ b/lib/CalypFrame.cpp @@ -451,7 +451,7 @@ std::uint64_t CalypFrame::getChromaLength() const return getWidth( 1 ) * getHeight( 1 ); } -unsigned int CalypFrame::getBitsPel() const +auto CalypFrame::getBitsPel() const -> unsigned int { return m_d->m_uiBitsPel; } @@ -1232,7 +1232,7 @@ bool CalypFrame::toMat( cv::Mat& cvMat, bool convertToGray, bool scale, unsigned { return bRet; } - auto numBytes = getBitsPel() > kNumBitsInByte ? 2 : 1; + unsigned numBytes = getBitsPel() > kNumBitsInByte ? 2 : 1; auto numChannels = getNumberChannels(); double scaleFactor = 1UL << ( numBytes * kNumBitsInByte - getBitsPel() ); if( scale == 0 ) scaleFactor = 1; @@ -1303,7 +1303,7 @@ auto CalypFrame::fromMat( cv::Mat& cvMat, int channel ) -> bool { bool bRet = false; #ifdef USE_OPENCV - auto numBytes = getBitsPel() > kNumBitsInByte ? 2 : 1; + unsigned numBytes = getBitsPel() > kNumBitsInByte ? 2 : 1; auto numChannels = getNumberChannels(); auto cvPrecision = getBitsPel() > kNumBitsInByte ? CV_16U : CV_8U; if( !m_d->m_bInit )