Files
ResInsight/ApplicationLibCode/UnitTests/RiuPlotUpdater-Test.cpp
T
Magne Sjaastad d30d5e7817 Fix crashes reported by crash telemetry
* Use guarded pointer for delayed plot updates

The cached result definition can be deleted before the delayed update is
executed, causing a crash in the PVT and relative permeability plot panels.

* Guard against fracture definition without conductivity result

The list of conductivity result names is empty for some fracture
definitions, causing an out of range access when computing statistics.

* Guard against missing data source in custom VFP plot

The data source of a VFP table can be null, and the VFP tables are not
available until the data has been imported.
2026-08-07 12:14:03 +02:00

60 lines
2.0 KiB
C++

#include "gtest/gtest.h"
#include "RimEclipseResultDefinition.h"
#include "Riu3dSelectionManager.h"
#include "RiuPlotUpdater.h"
#include <QWidget>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class TestPlotUpdater : public RiuPlotUpdater
{
public:
void storeSelection( const RiuEclipseSelectionItem* selectionItem ) { storeDelayedInformation( selectionItem ); }
int queryCount() const { return m_queryCount; }
protected:
void clearPlot() override {}
QWidget* plotPanel() override { return nullptr; }
bool queryDataAndUpdatePlot( const RimEclipseResultDefinition* eclipseResDef, size_t, size_t, size_t ) override
{
m_queryCount++;
return true;
}
private:
int m_queryCount = 0;
};
//--------------------------------------------------------------------------------------------------
/// The result definition can be deleted between the selection change and the delayed update
//--------------------------------------------------------------------------------------------------
TEST( RiuPlotUpdaterTest, DelayedUpdateAfterResultDefinitionIsDeleted )
{
auto* resultDefinition = new RimEclipseResultDefinition;
RiuEclipseSelectionItem selectionItem( nullptr,
resultDefinition,
0,
0,
0,
0,
cvf::Color3f( 1.0f, 0.0f, 0.0f ),
cvf::StructGridInterface::NO_FACE,
cvf::Vec3d::ZERO );
TestPlotUpdater plotUpdater;
plotUpdater.storeSelection( &selectionItem );
delete resultDefinition;
plotUpdater.doDelayedUpdate();
EXPECT_EQ( 0, plotUpdater.queryCount() );
}