#14493 Clear referring curve sets directly when an ensemble is deleted

The destructor called updateReferringCurveSets(), which runs loadDataAndUpdate() on every referring curve set. At that point the summary cases are already deleted, so reloading the curve data has nothing to read. The reload also syncs UI fields, reloads the curve filters, rebuilds the address list, recomputes statistics over an empty case set and updates three legends, and it calls updateAll() on the parent plot once per curve set instead of once per plot.

Add clearReferringCurveSets(), which deletes the ensemble and statistics curves directly and updates each affected plot once. For an ensemble with many realizations spread over several curve sets in the same plot this removes most of the work done while deleting.

Query the referring objects as RimEnsembleCurveSet instead of walking all referring objects and casting. The previous loop discarded everything that was not a curve set, so the behavior is unchanged.
This commit is contained in:
Magne Sjaastad
2026-08-10 12:38:41 +02:00
parent 6bdccdf074
commit 1d4a15fd89
2 changed files with 35 additions and 1 deletions
@@ -53,6 +53,7 @@
#include <QFileInfo>
#include <cmath>
#include <set>
CAF_PDM_SOURCE_INIT( RimSummaryEnsemble, "SummaryCaseSubCollection" );
@@ -118,7 +119,8 @@ RimSummaryEnsemble::~RimSummaryEnsemble()
{
m_cases.deleteChildren();
updateReferringCurveSets();
// The cases are gone at this point, so the referring curve sets are cleared and their plots redrawn without data.
clearReferringCurveSets();
}
//--------------------------------------------------------------------------------------------------
@@ -787,6 +789,37 @@ void RimSummaryEnsemble::updateReferringCurveSets()
updateReferringCurveSets( false );
}
//--------------------------------------------------------------------------------------------------
/// Clear the curves of the curve sets referring to this ensemble, and redraw the affected plots.
///
/// Used when the summary cases have been deleted. Reloading the curve data has nothing to read at that point, so this
/// deletes the curves directly instead of going through loadDataAndUpdate(). Each plot is updated once, even when it
/// holds several curve sets referring to this ensemble.
//--------------------------------------------------------------------------------------------------
void RimSummaryEnsemble::clearReferringCurveSets()
{
std::set<RimSummaryPlot*> plotsToUpdate;
for ( auto curveSet : objectsWithReferringPtrFieldsOfType<RimEnsembleCurveSet>() )
{
if ( !curveSet ) continue;
curveSet->deleteEnsembleCurves();
curveSet->deleteStatisticsCurves();
curveSet->filterChanged.send();
if ( auto parentPlot = curveSet->firstAncestorOrThisOfType<RimSummaryPlot>() )
{
plotsToUpdate.insert( parentPlot );
}
}
for ( auto plot : plotsToUpdate )
{
plot->updateAll();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -113,6 +113,7 @@ public:
void updateReferringCurveSets();
void updateReferringCurveSetsZoomAll();
void clearReferringCurveSets();
RiaSummaryAddressAnalyzer* addressAnalyzer();