From 24d58e3a98924869c3068f28f4fa1c54924ae351 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 13 May 2020 11:50:10 +0200 Subject: [PATCH] Fix crash in WBS curves when rkb diff is 0 --- .../RimWellLogExtractionCurve.cpp | 7 +++-- .../RigWellLogCurveData.cpp | 31 +++++++++---------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp index 8b387d9bc6..429909ad98 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp @@ -350,9 +350,10 @@ void RimWellLogExtractionCurve::onLoadDataAndUpdate( bool updateParentPlot ) isUsingPseudoLength = false; } - m_qwtPlotCurve->setSamples( curveData()->xPlotValues().data(), - curveData()->depthPlotValues( depthType, displayUnit ).data(), - static_cast( curveData()->xPlotValues().size() ) ); + std::vector xPlotValues = curveData()->xPlotValues(); + std::vector depthPlotValues = curveData()->depthPlotValues( depthType, displayUnit ); + CAF_ASSERT( xPlotValues.size() == depthPlotValues.size() ); + m_qwtPlotCurve->setSamples( xPlotValues.data(), depthPlotValues.data(), static_cast( xPlotValues.size() ) ); m_qwtPlotCurve->setLineSegmentStartStopIndices( curveData()->polylineStartStopIndices() ); diff --git a/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp b/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp index bbe2fc0629..824d7823e9 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp @@ -148,28 +148,25 @@ std::vector RigWellLogCurveData::depths( RiaDefines::DepthTypeEnum depth return it->second; } - if ( m_rkbDiff != 0.0 ) + if ( depthType == RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH_RKB && + m_depths.count( RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH ) ) { - if ( depthType == RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH_RKB && - m_depths.count( RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH ) ) + std::vector tvds = depths( RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH ); + for ( double& tvdValue : tvds ) { - std::vector tvds = depths( RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH ); - for ( double& tvdValue : tvds ) - { - tvdValue += m_rkbDiff; - } - return tvds; + tvdValue += m_rkbDiff; } - else if ( depthType == RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH && - m_depths.count( RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH_RKB ) ) + return tvds; + } + else if ( depthType == RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH && + m_depths.count( RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH_RKB ) ) + { + std::vector tvds = depths( RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH_RKB ); + for ( double& tvdValue : tvds ) { - std::vector tvds = depths( RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH_RKB ); - for ( double& tvdValue : tvds ) - { - tvdValue -= m_rkbDiff; - } - return tvds; + tvdValue -= m_rkbDiff; } + return tvds; } return std::vector(); }