Skip to content

Commit

Permalink
#12020 Delay the call to updateConnectedEditors
Browse files Browse the repository at this point in the history
Make sure the call to updateConnectedEditors happens after other slots have been processed. Also make sure that the call is done only once.
  • Loading branch information
magnesj committed Jan 3, 2025
1 parent 45c8916 commit eead663
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ RimGridCrossPlotDataSet::RimGridCrossPlotDataSet()

setDefaults();
setDeletable( true );

m_updateConnectedEditorsIsScheduled = false;
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -1421,7 +1423,28 @@ void RimGridCrossPlotDataSet::triggerPlotNameUpdateAndReplot()
{
parent->updateCurveNamesAndPlotTitle();
parent->reattachAllCurves();
parent->updateConnectedEditors();

// updateConnectedEditors() causes the UI editor to be recreated (and the widgets contained in the UI editor). The function calling
// this function can in some cases comes from the widget to be destroyed, typically the tree view selection editor displaying
// available result properties. Use a flag to make sure that updateConnectedEditors() is only called once. Using a QTimer to
// schedule the call will ensure that all other slots are processed before the updateConnectedEditors() is called.

if ( !m_updateConnectedEditorsIsScheduled )
{
m_updateConnectedEditorsIsScheduled = true;

QTimer::singleShot( 1,
[&]()
{
// Get the parent again, as the parent pointer might be invalid at this point
if ( auto p = firstAncestorOrThisOfType<RimGridCrossPlot>() )
{
p->updateConnectedEditors();
}

m_updateConnectedEditorsIsScheduled = false;
} );
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,6 @@ class RimGridCrossPlotDataSet : public RimCheckableNamedObject, public RimNameCo
caf::PdmChildField<RimPlotCellFilterCollection*> m_plotCellFilterCollection;

QPointer<RiuDraggableOverlayFrame> m_legendOverlayFrame;

bool m_updateConnectedEditorsIsScheduled;
};

0 comments on commit eead663

Please sign in to comment.