Use deleteChildren() when required to avoid memory leak

This commit is contained in:
Magne Sjaastad 2022-05-31 12:56:45 +02:00
parent 950ec38a14
commit 6a5b9f7300
11 changed files with 14 additions and 14 deletions

View File

@ -1117,7 +1117,7 @@ void WellSummaryPage::initializePage()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void WellSummaryPage::updateSummaryPage() void WellSummaryPage::updateSummaryPage()
{ {
m_objectGroup->objects.clearWithoutDelete(); m_objectGroup->objects.deleteChildren();
m_textEdit->setText( "Summary of imported wells\n\n" ); m_textEdit->setText( "Summary of imported wells\n\n" );

View File

@ -270,7 +270,7 @@ void RimFaultRASettings::initFromPreprocSettings( RimFaultRAPreprocSettings* pre
RifParameterXmlReader basicreader( RiaPreferencesGeoMech::current()->geomechFRADefaultBasicXML() ); RifParameterXmlReader basicreader( RiaPreferencesGeoMech::current()->geomechFRADefaultBasicXML() );
if ( !basicreader.parseFile( errorText ) ) return; if ( !basicreader.parseFile( errorText ) ) return;
m_basicParameters.clearWithoutDelete(); m_basicParameters.deleteChildren();
for ( auto group : basicreader.parameterGroups() ) for ( auto group : basicreader.parameterGroups() )
{ {
m_basicParameters.push_back( group ); m_basicParameters.push_back( group );
@ -281,7 +281,7 @@ void RimFaultRASettings::initFromPreprocSettings( RimFaultRAPreprocSettings* pre
RifParameterXmlReader advreader( RiaPreferencesGeoMech::current()->geomechFRADefaultAdvXML() ); RifParameterXmlReader advreader( RiaPreferencesGeoMech::current()->geomechFRADefaultAdvXML() );
if ( !advreader.parseFile( errorText ) ) return; if ( !advreader.parseFile( errorText ) ) return;
m_advancedParameters.clearWithoutDelete(); m_advancedParameters.deleteChildren();
for ( auto group : advreader.parameterGroups() ) for ( auto group : advreader.parameterGroups() )
{ {
m_advancedParameters.push_back( group ); m_advancedParameters.push_back( group );

View File

@ -1045,7 +1045,7 @@ void RimWellPltPlot::initAfterLoad()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellPltPlot::syncSourcesIoFieldFromGuiField() void RimWellPltPlot::syncSourcesIoFieldFromGuiField()
{ {
m_selectedSourcesForIo.clearWithoutDelete(); m_selectedSourcesForIo.deleteChildren();
for ( const RifDataSourceForRftPlt& addr : m_selectedSources() ) for ( const RifDataSourceForRftPlt& addr : m_selectedSources() )
{ {

View File

@ -69,7 +69,7 @@ void RimGeoMechPartCollection::syncWithCase( RimGeoMechCase* geoCase )
if ( count != (int)m_parts.size() ) if ( count != (int)m_parts.size() )
{ {
m_parts.clearWithoutDelete(); m_parts.deleteChildren();
for ( int i = 0; i < count; i++ ) for ( int i = 0; i < count; i++ )
{ {

View File

@ -167,7 +167,7 @@ void RimCustomObjectiveFunctionWeight::fieldChangedByUi( const caf::PdmFieldHand
auto curveSelection = dlg.curveSelection(); auto curveSelection = dlg.curveSelection();
if ( !curveSelection.empty() ) if ( !curveSelection.empty() )
{ {
m_objectiveValuesSummaryAddresses.clearWithoutDelete(); m_objectiveValuesSummaryAddresses.deleteChildren();
for ( auto address : curveSelection ) for ( auto address : curveSelection )
{ {
RimSummaryAddress* summaryAddress = new RimSummaryAddress(); RimSummaryAddress* summaryAddress = new RimSummaryAddress();

View File

@ -425,7 +425,7 @@ void RimPlotAxisProperties::appendAnnotation( RimPlotAxisAnnotation* annotation
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimPlotAxisProperties::removeAllAnnotations() void RimPlotAxisProperties::removeAllAnnotations()
{ {
m_annotations.clearWithoutDelete(); m_annotations.deleteChildren();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -441,7 +441,7 @@ void RimStreamlineInViewCollection::updateStreamlines()
if ( m_shouldGenerateTracers && isActive() ) if ( m_shouldGenerateTracers && isActive() )
{ {
// reset generated streamlines // reset generated streamlines
m_streamlines().clearWithoutDelete(); m_streamlines.deleteChildren();
m_wellCellIds.clear(); m_wellCellIds.clear();
// get current simulation timestep // get current simulation timestep

View File

@ -238,7 +238,7 @@ std::vector<RifEclipseSummaryAddress> RimEnsembleCurveFilter::summaryAddresses()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimEnsembleCurveFilter::setSummaryAddresses( std::vector<RifEclipseSummaryAddress> addresses ) void RimEnsembleCurveFilter::setSummaryAddresses( std::vector<RifEclipseSummaryAddress> addresses )
{ {
m_objectiveValuesSummaryAddresses.clearWithoutDelete(); m_objectiveValuesSummaryAddresses.deleteChildren();
for ( auto address : addresses ) for ( auto address : addresses )
{ {
RimSummaryAddress* summaryAddress = new RimSummaryAddress(); RimSummaryAddress* summaryAddress = new RimSummaryAddress();
@ -396,7 +396,7 @@ void RimEnsembleCurveFilter::fieldChangedByUi( const caf::PdmFieldHandle* change
auto curveSelection = dlg.curveSelection(); auto curveSelection = dlg.curveSelection();
if ( !curveSelection.empty() ) if ( !curveSelection.empty() )
{ {
m_objectiveValuesSummaryAddresses.clearWithoutDelete(); m_objectiveValuesSummaryAddresses.deleteChildren();
for ( auto address : curveSelection ) for ( auto address : curveSelection )
{ {
RimSummaryAddress* summaryAddress = new RimSummaryAddress(); RimSummaryAddress* summaryAddress = new RimSummaryAddress();

View File

@ -820,7 +820,7 @@ void RimEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* changedFi
auto curveSelection = dlg.curveSelection(); auto curveSelection = dlg.curveSelection();
if ( !curveSelection.empty() ) if ( !curveSelection.empty() )
{ {
m_objectiveValuesSummaryAddresses.clearWithoutDelete(); m_objectiveValuesSummaryAddresses.deleteChildren();
for ( auto address : curveSelection ) for ( auto address : curveSelection )
{ {
RimSummaryAddress* summaryAddress = new RimSummaryAddress(); RimSummaryAddress* summaryAddress = new RimSummaryAddress();

View File

@ -532,7 +532,7 @@ void RimSummaryTimeAxisProperties::appendAnnotation( RimPlotAxisAnnotation* anno
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimSummaryTimeAxisProperties::removeAllAnnotations() void RimSummaryTimeAxisProperties::removeAllAnnotations()
{ {
m_annotations.clearWithoutDelete(); m_annotations.deleteChildren();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -116,7 +116,7 @@ bool RimWellIASettings::initSettings( QString& outErrmsg )
RifParameterXmlReader basicreader( RiaPreferencesGeoMech::current()->geomechWIADefaultXML() ); RifParameterXmlReader basicreader( RiaPreferencesGeoMech::current()->geomechWIADefaultXML() );
if ( !basicreader.parseFile( outErrmsg ) ) return false; if ( !basicreader.parseFile( outErrmsg ) ) return false;
m_parameters.clearWithoutDelete(); m_parameters.deleteChildren();
for ( auto group : basicreader.parameterGroups() ) for ( auto group : basicreader.parameterGroups() )
{ {
m_parameters.push_back( group ); m_parameters.push_back( group );
@ -525,7 +525,7 @@ void RimWellIASettings::addCsvGroup( QString name, QStringList timeSteps, double
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellIASettings::initCsvParameters() void RimWellIASettings::initCsvParameters()
{ {
m_csvParameters.clearWithoutDelete(); m_csvParameters.deleteChildren();
QStringList timeSteps = m_geomechCase->timeStepStrings(); QStringList timeSteps = m_geomechCase->timeStepStrings();