mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
AppFwk: Fix missing type guard in multi select field edit code. Added Assert in updateUI to prevent accidental recursive calling.
This commit is contained in:
@@ -86,10 +86,15 @@ void PdmUiCommandSystemProxy::setUiValueToField(PdmUiFieldHandle* uiFieldHandle,
|
|||||||
{
|
{
|
||||||
// Handle editing multiple objects when several objects are selected
|
// Handle editing multiple objects when several objects are selected
|
||||||
PdmFieldHandle* editorField = uiFieldHandle->fieldHandle();
|
PdmFieldHandle* editorField = uiFieldHandle->fieldHandle();
|
||||||
|
const std::type_info& fieldOwnerTypeId = typeid( *editorField->ownerObject());
|
||||||
|
|
||||||
std::vector<PdmFieldHandle*> fieldsToUpdate;
|
std::vector<PdmFieldHandle*> fieldsToUpdate;
|
||||||
fieldsToUpdate.push_back(editorField);
|
fieldsToUpdate.push_back(editorField);
|
||||||
|
|
||||||
// For current selection, find all fields with same keyword
|
// For current selection, find all fields with same keyword
|
||||||
|
// Todo: Should traverse the ui ordering and find all fields with same keyword and same ownerobject type.
|
||||||
|
// Until we do, fields embedded into the proerty panel fram a different object will not work with multiselection edit
|
||||||
|
// For now we only makes sure we have same ownerobject type
|
||||||
{
|
{
|
||||||
std::vector<PdmUiItem*> items;
|
std::vector<PdmUiItem*> items;
|
||||||
SelectionManager::instance()->selectedItems(items, SelectionManager::CURRENT);
|
SelectionManager::instance()->selectedItems(items, SelectionManager::CURRENT);
|
||||||
@@ -98,7 +103,7 @@ void PdmUiCommandSystemProxy::setUiValueToField(PdmUiFieldHandle* uiFieldHandle,
|
|||||||
for (size_t i = 0; i < items.size(); i++)
|
for (size_t i = 0; i < items.size(); i++)
|
||||||
{
|
{
|
||||||
PdmObjectHandle* objectHandle = dynamic_cast<PdmObjectHandle*>(items[i]);
|
PdmObjectHandle* objectHandle = dynamic_cast<PdmObjectHandle*>(items[i]);
|
||||||
if (objectHandle)
|
if (objectHandle && typeid( *objectHandle) == fieldOwnerTypeId)
|
||||||
{
|
{
|
||||||
// An object is selected, find field with same keyword as the current field being edited
|
// An object is selected, find field with same keyword as the current field being edited
|
||||||
PdmFieldHandle* fieldHandle = objectHandle->findField(editorField->keyword());
|
PdmFieldHandle* fieldHandle = objectHandle->findField(editorField->keyword());
|
||||||
|
|||||||
@@ -43,7 +43,9 @@ namespace caf
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
PdmUiEditorHandle::PdmUiEditorHandle() : m_pdmItem(nullptr)
|
PdmUiEditorHandle::PdmUiEditorHandle()
|
||||||
|
: m_pdmItem(nullptr)
|
||||||
|
, m_isConfiguringUi(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -56,6 +58,29 @@ PdmUiEditorHandle::~PdmUiEditorHandle()
|
|||||||
if (m_pdmItem) m_pdmItem->removeFieldEditor(this);
|
if (m_pdmItem) m_pdmItem->removeFieldEditor(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void PdmUiEditorHandle::updateUi(const QString& uiConfigName)
|
||||||
|
{
|
||||||
|
CAF_ASSERT(!m_isConfiguringUi);
|
||||||
|
m_isConfiguringUi = true;
|
||||||
|
m_currentConfigName = uiConfigName;
|
||||||
|
this->configureAndUpdateUi(uiConfigName);
|
||||||
|
m_isConfiguringUi = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void PdmUiEditorHandle::updateUi()
|
||||||
|
{
|
||||||
|
CAF_ASSERT(!m_isConfiguringUi);
|
||||||
|
m_isConfiguringUi = true;
|
||||||
|
this->configureAndUpdateUi(m_currentConfigName);
|
||||||
|
m_isConfiguringUi = false;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -57,22 +57,15 @@ public:
|
|||||||
virtual ~PdmUiEditorHandle();
|
virtual ~PdmUiEditorHandle();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
void updateUi(const QString& uiConfigName);;
|
||||||
|
|
||||||
|
void updateUi();;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Interface to override:
|
||||||
/// Virtual method to be overridden. Needs to set up the supplied widget
|
/// Virtual method to be overridden. Needs to set up the supplied widget
|
||||||
/// with all signals etc to make it communicate with this object
|
/// with all signals etc to make it communicate with this object
|
||||||
|
|
||||||
void updateUi(const QString& uiConfigName)
|
|
||||||
{
|
|
||||||
m_currentConfigName = uiConfigName;
|
|
||||||
this->configureAndUpdateUi(uiConfigName);
|
|
||||||
};
|
|
||||||
|
|
||||||
void updateUi()
|
|
||||||
{
|
|
||||||
this->configureAndUpdateUi(m_currentConfigName);
|
|
||||||
};
|
|
||||||
|
|
||||||
protected: // Interface to override:
|
|
||||||
|
|
||||||
/// Supposed to update all parts of the widgets, both visibility, sensitivity, decorations and field data
|
/// Supposed to update all parts of the widgets, both visibility, sensitivity, decorations and field data
|
||||||
virtual void configureAndUpdateUi(const QString& uiConfigName) = 0;
|
virtual void configureAndUpdateUi(const QString& uiConfigName) = 0;
|
||||||
|
|
||||||
@@ -86,6 +79,8 @@ private:
|
|||||||
friend PdmUiItem::~PdmUiItem();
|
friend PdmUiItem::~PdmUiItem();
|
||||||
PdmUiItem* m_pdmItem;
|
PdmUiItem* m_pdmItem;
|
||||||
QString m_currentConfigName;
|
QString m_currentConfigName;
|
||||||
|
|
||||||
|
bool m_isConfiguringUi;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ PdmUiFieldHandle::PdmUiFieldHandle(PdmFieldHandle* owner, bool giveOwnership):
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void PdmUiFieldHandle::notifyFieldChanged(const QVariant& oldFieldValue, const QVariant& newFieldValue)
|
void PdmUiFieldHandle::notifyFieldChanged(const QVariant& oldFieldValue, const QVariant& newFieldValue)
|
||||||
{
|
{
|
||||||
|
// Todo : Should use a virtual version of isElementEqual. The variant != operation will not work on user types
|
||||||
|
|
||||||
if (oldFieldValue != newFieldValue)
|
if (oldFieldValue != newFieldValue)
|
||||||
{
|
{
|
||||||
PdmFieldHandle* fieldHandle = this->fieldHandle();
|
PdmFieldHandle* fieldHandle = this->fieldHandle();
|
||||||
|
|||||||
@@ -390,9 +390,12 @@ void caf::PdmUiWidgetBasedObjectEditor::configureAndUpdateUi(const QString& uiCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
/// Unused. Should probably remove
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void caf::PdmUiWidgetBasedObjectEditor::recursiveVerifyUniqueNames(const std::vector<PdmUiItem*>& uiItems, const QString& uiConfigName, std::set<QString>* fieldKeywordNames, std::set<QString>* groupNames)
|
void caf::PdmUiWidgetBasedObjectEditor::recursiveVerifyUniqueNames(const std::vector<PdmUiItem*>& uiItems,
|
||||||
|
const QString& uiConfigName,
|
||||||
|
std::set<QString>* fieldKeywordNames,
|
||||||
|
std::set<QString>* groupNames)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < uiItems.size(); ++i)
|
for (size_t i = 0; i < uiItems.size(); ++i)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user