Skip to content

Commit

Permalink
Merge pull request #214 from K-os/fix_gh213_implicit_downcast_exception
Browse files Browse the repository at this point in the history
Fix GH#213 implicit downcast exception
  • Loading branch information
adamjw24 authored Nov 11, 2024
2 parents 31d0e25 + 9bc0741 commit b0195db
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions source/Lib/CommonLib/TypeDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,10 @@ class Exception : public std::exception
virtual ~Exception() noexcept = default;
CLASS_COPY_MOVE_DEFAULT( Exception )

virtual const char* what() const noexcept { return m_str.c_str(); }
template<typename T> Exception& operator<<( const T& t ) { std::ostringstream oss; oss << t; m_str += oss.str(); return *this; }
virtual const char* what() const noexcept { return m_str.c_str(); }
template<typename T>
inline Exception& operator<<( const T& t ) { std::ostringstream oss; oss << t; m_str += oss.str(); return *this; }

private:
std::string m_str;
};
Expand All @@ -755,6 +757,9 @@ class RecoverableException : public Exception
explicit RecoverableException( const std::string& _s ) : Exception( _s ) {}
virtual ~RecoverableException() noexcept = default;
CLASS_COPY_MOVE_DEFAULT( RecoverableException )

template<typename T>
inline RecoverableException& operator<<( const T& t ) { static_cast<Exception&>( *this ) << t; return *this; }
};

class UnsupportedFeatureException : public Exception
Expand All @@ -763,6 +768,9 @@ class UnsupportedFeatureException : public Exception
explicit UnsupportedFeatureException( const std::string& _s ) : Exception( _s ) {}
virtual ~UnsupportedFeatureException() noexcept = default;
CLASS_COPY_MOVE_DEFAULT( UnsupportedFeatureException )

template<typename T>
inline UnsupportedFeatureException& operator<<( const T& t ) { static_cast<Exception&>( *this ) << t; return *this; }
};

#if defined( __MINGW32__ ) && !defined( __MINGW64__ )
Expand Down
2 changes: 1 addition & 1 deletion source/Lib/DecoderLib/DecLibParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ bool DecLibParser::parse( InputNALUnit& nalu )
const VPS* vps = m_parameterSetManager.getVPS( sps->getVPSId() );
m_seiReader.parseSEImessage( &( nalu.getBitstream() ), m_pcParsePic->seiMessageList, nalu.m_nalUnitType, nalu.m_nuhLayerId, nalu.m_temporalId, vps, sps, m_HRD, m_pDecodedSEIOutputStream );

if( m_parseFrameDelay == 0 ) // else it has to be done in finishPicture()
if( m_parseFrameDelay == 0 && !m_pcParsePic->error ) // if m_parseFrameDelay > 0, it has to be done in finishPicture()
{
// if parallel parsing is disabled, wait for the picture to finish
if( m_threadPool->numThreads() == 0 )
Expand Down

0 comments on commit b0195db

Please sign in to comment.