Make sure toolbar is updated for when a single plot is present

We try to update the content of the toolbar only when required, as this can take some time to produce the combo box content for large cases. Return false to make sure the UI is rebuild if any invalid text is present.
This commit is contained in:
Magne Sjaastad 2023-11-17 10:46:44 +01:00
parent 5bba0eaea8
commit f092f18614

View File

@ -80,25 +80,29 @@ PdmUiToolBarEditor::~PdmUiToolBarEditor()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool PdmUiToolBarEditor::isEditorDataEqualAndValid( const std::vector<caf::PdmFieldHandle*>& fields ) const bool PdmUiToolBarEditor::isEditorDataEqualAndValid( const std::vector<caf::PdmFieldHandle*>& fields ) const
{ {
if ( m_fields.size() == fields.size() && m_fieldViews.size() == fields.size() ) if ( m_fields.size() != fields.size() || m_fieldViews.size() != fields.size() )
{ {
bool equalContent = true; return false;
}
for ( size_t i = 0; i < m_fields.size(); i++ ) for ( size_t i = 0; i < m_fields.size(); i++ )
{
auto currentField = m_fields[i];
if ( currentField != fields[i] )
{ {
if ( m_fields[i] != fields[i] ) return false;
{
equalContent = false;
}
} }
if ( equalContent ) if ( currentField && currentField->uiCapability() )
{ {
return true; auto contentText = currentField->uiCapability()->uiValue();
// If there is no selection in a combo box, the content text is "-1"
// Rebuild the UI to make sure the available items in the combo box is updated
if ( contentText == "-1" ) return false;
} }
} }
return false; return true;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------