mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-12 16:32:12 -05:00
#2142 AppFwk : Guard null pointer access
This commit is contained in:
1 parent
cfaf27d4bf
commit
733b1b5260
2 files changed
+26
-11
No files matched your search
@@ -118,7 +118,7 @@ QVariant PdmUiTableViewModel::headerData(int section, Qt::Orientation orientatio
|
||||
{
|
||||
if (orientation == Qt::Horizontal)
|
||||
{
|
||||
PdmUiFieldHandle* uiFieldHandle = getField(createIndex(0, section))->uiCapability();
|
||||
PdmUiFieldHandle* uiFieldHandle = getUiFieldHandle(createIndex(0, section));
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
return uiFieldHandle->uiName(m_currentConfigName);
|
||||
@@ -152,8 +152,7 @@ Qt::ItemFlags PdmUiTableViewModel::flags(const QModelIndex &index) const
|
||||
flagMask = flagMask | Qt::ItemIsEditable;
|
||||
}
|
||||
|
||||
PdmFieldHandle* field = getField(index);
|
||||
PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
||||
PdmUiFieldHandle* uiFieldHandle = getUiFieldHandle(index);
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
if (uiFieldHandle->isUiReadOnly(m_currentConfigName))
|
||||
@@ -177,12 +176,14 @@ bool PdmUiTableViewModel::setData(const QModelIndex &index, const QVariant &valu
|
||||
SelectionManager::instance()->clear(SelectionManager::CURRENT);
|
||||
|
||||
bool toggleOn = (value == Qt::Checked);
|
||||
PdmFieldHandle* field = getField(index);
|
||||
|
||||
PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
||||
PdmUiCommandSystemProxy::instance()->setUiValueToField(uiFieldHandle, toggleOn);
|
||||
PdmUiFieldHandle* uiFieldHandle = getUiFieldHandle(index);
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
PdmUiCommandSystemProxy::instance()->setUiValueToField(uiFieldHandle, toggleOn);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -534,6 +535,20 @@ void PdmUiTableViewModel::recreateTableItemEditors()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmUiFieldHandle* PdmUiTableViewModel::getUiFieldHandle(const QModelIndex& index) const
|
||||
{
|
||||
auto fieldHandle = getField(index);
|
||||
if (fieldHandle)
|
||||
{
|
||||
return fieldHandle->uiCapability();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -57,6 +57,9 @@ class PdmUiTreeOrdering;
|
||||
class PdmUiTreeViewEditor;
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class TableViewPushButton : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -71,10 +74,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -108,6 +107,7 @@ public:
|
||||
private:
|
||||
int getFieldIndex(PdmFieldHandle* field) const;
|
||||
void recreateTableItemEditors();
|
||||
PdmUiFieldHandle* getUiFieldHandle(const QModelIndex& index) const;
|
||||
|
||||
friend class PdmUiTableViewDelegate;
|
||||
QWidget* getEditorWidgetAndTransferOwnership(QWidget* parent, const QModelIndex &index);
|
||||
|
||||
Reference in new issue
Block a user