From de4fafe744e96cc7a4a86613a82d04bd200215f3 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 May 2020 14:37:51 +0200 Subject: [PATCH] Fix crash in WBS curves when rkb diff is 0 (ported to patch branch) --- .../RimWellLogExtractionCurve.cpp | 7 ++-- .../RigWellLogCurveData.cpp | 32 +++++++++---------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp index 4bf3e65f6c..f4be3a33d3 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 1ecb03904d..bf09fbd313 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp @@ -147,27 +147,25 @@ std::vector RigWellLogCurveData::depths( RiaDefines::DepthTypeEnum depth return it->second; } - if ( m_rkbDiff != 0.0 ) + if ( depthType == RiaDefines::TRUE_VERTICAL_DEPTH_RKB && m_depths.count( RiaDefines::TRUE_VERTICAL_DEPTH ) ) { - if ( depthType == RiaDefines::TRUE_VERTICAL_DEPTH_RKB && m_depths.count( RiaDefines::TRUE_VERTICAL_DEPTH ) ) + std::vector tvds = depths( RiaDefines::TRUE_VERTICAL_DEPTH ); + for ( double& tvdValue : tvds ) { - std::vector tvds = depths( RiaDefines::TRUE_VERTICAL_DEPTH ); - for ( double& tvdValue : tvds ) - { - tvdValue += m_rkbDiff; - } - return tvds; - } - else if ( depthType == RiaDefines::TRUE_VERTICAL_DEPTH && m_depths.count( RiaDefines::TRUE_VERTICAL_DEPTH_RKB ) ) - { - std::vector tvds = depths( RiaDefines::TRUE_VERTICAL_DEPTH_RKB ); - for ( double& tvdValue : tvds ) - { - tvdValue -= m_rkbDiff; - } - return tvds; + tvdValue += m_rkbDiff; } + return tvds; } + else if ( depthType == RiaDefines::TRUE_VERTICAL_DEPTH && m_depths.count( RiaDefines::TRUE_VERTICAL_DEPTH_RKB ) ) + { + std::vector tvds = depths( RiaDefines::TRUE_VERTICAL_DEPTH_RKB ); + for ( double& tvdValue : tvds ) + { + tvdValue -= m_rkbDiff; + } + return tvds; + } + return std::vector(); }