Avoid overwrite of axis object for newer project file versions

Add project file version check to the usage of m_plotAxis_OBSOLETE in RimSummaryCurve::initAfterRead()
This commit is contained in:
Magne Sjaastad committed 2025-08-07 13:45:08 +02:00
1 parent 43fa4197c7
commit b0a86de653
2 files changed
+6 -3

No files matched your search

@@ -45,6 +45,9 @@ bool isCandidateNewerThanOther( int candidateMajorVersion,
return ( candidateMajorVersion > otherMajorVersion ); return ( candidateMajorVersion > otherMajorVersion );
} }
// Early exit if a minor number is undefined
if ( candidateMinorVersion == -1 || otherMinorVersion == -1 ) return false;
if ( candidateMinorVersion != otherMinorVersion ) if ( candidateMinorVersion != otherMinorVersion )
{ {
return ( candidateMinorVersion > otherMinorVersion ); return ( candidateMinorVersion > otherMinorVersion );
@@ -102,7 +105,7 @@ QString stringOfDigits( const QString& string )
bool RiaProjectFileTools::isCandidateVersionNewerThanOther( const QString& candidateProjectFileVersion, const QString& projectFileVersion ) bool RiaProjectFileTools::isCandidateVersionNewerThanOther( const QString& candidateProjectFileVersion, const QString& projectFileVersion )
{ {
int candidateMajorVersion = 0; int candidateMajorVersion = 0;
int candidateMinorVersion = 0; int candidateMinorVersion = -1;
int candidatePatchNumber = -1; int candidatePatchNumber = -1;
int candidateDevelopmentId = -1; int candidateDevelopmentId = -1;
@@ -113,7 +116,7 @@ bool RiaProjectFileTools::isCandidateVersionNewerThanOther( const QString& candi
&candidateDevelopmentId ); &candidateDevelopmentId );
int majorVersion = 0; int majorVersion = 0;
int minorVersion = 0; int minorVersion = -1;
int patchNumber = -1; int patchNumber = -1;
int developmentId = -1; int developmentId = -1;
@@ -791,7 +791,7 @@ void RimSummaryCurve::initAfterRead()
{ {
RimStackablePlotCurve::initAfterRead(); RimStackablePlotCurve::initAfterRead();
if ( m_yPlotAxisProperties.value() == nullptr ) if ( RimProject::current()->isProjectFileVersionEqualOrOlderThan( "2021" ) && m_yPlotAxisProperties.value() == nullptr )
{ {
auto plot = firstAncestorOrThisOfType<RimSummaryPlot>(); auto plot = firstAncestorOrThisOfType<RimSummaryPlot>();
if ( plot ) m_yPlotAxisProperties = plot->axisPropertiesForPlotAxis( RiuPlotAxis( m_plotAxis_OBSOLETE() ) ); if ( plot ) m_yPlotAxisProperties = plot->axisPropertiesForPlotAxis( RiuPlotAxis( m_plotAxis_OBSOLETE() ) );