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)
|
if (orientation == Qt::Horizontal)
|
||||||
{
|
{
|
||||||
PdmUiFieldHandle* uiFieldHandle = getField(createIndex(0, section))->uiCapability();
|
PdmUiFieldHandle* uiFieldHandle = getUiFieldHandle(createIndex(0, section));
|
||||||
if (uiFieldHandle)
|
if (uiFieldHandle)
|
||||||
{
|
{
|
||||||
return uiFieldHandle->uiName(m_currentConfigName);
|
return uiFieldHandle->uiName(m_currentConfigName);
|
||||||
@@ -152,8 +152,7 @@ Qt::ItemFlags PdmUiTableViewModel::flags(const QModelIndex &index) const
|
|||||||
flagMask = flagMask | Qt::ItemIsEditable;
|
flagMask = flagMask | Qt::ItemIsEditable;
|
||||||
}
|
}
|
||||||
|
|
||||||
PdmFieldHandle* field = getField(index);
|
PdmUiFieldHandle* uiFieldHandle = getUiFieldHandle(index);
|
||||||
PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
|
||||||
if (uiFieldHandle)
|
if (uiFieldHandle)
|
||||||
{
|
{
|
||||||
if (uiFieldHandle->isUiReadOnly(m_currentConfigName))
|
if (uiFieldHandle->isUiReadOnly(m_currentConfigName))
|
||||||
@@ -177,12 +176,14 @@ bool PdmUiTableViewModel::setData(const QModelIndex &index, const QVariant &valu
|
|||||||
SelectionManager::instance()->clear(SelectionManager::CURRENT);
|
SelectionManager::instance()->clear(SelectionManager::CURRENT);
|
||||||
|
|
||||||
bool toggleOn = (value == Qt::Checked);
|
bool toggleOn = (value == Qt::Checked);
|
||||||
PdmFieldHandle* field = getField(index);
|
|
||||||
|
|
||||||
PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
PdmUiFieldHandle* uiFieldHandle = getUiFieldHandle(index);
|
||||||
PdmUiCommandSystemProxy::instance()->setUiValueToField(uiFieldHandle, toggleOn);
|
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 PdmUiTreeViewEditor;
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
class TableViewPushButton : public QPushButton
|
class TableViewPushButton : public QPushButton
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -71,10 +74,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//==================================================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==================================================================================================
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -108,6 +107,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
int getFieldIndex(PdmFieldHandle* field) const;
|
int getFieldIndex(PdmFieldHandle* field) const;
|
||||||
void recreateTableItemEditors();
|
void recreateTableItemEditors();
|
||||||
|
PdmUiFieldHandle* getUiFieldHandle(const QModelIndex& index) const;
|
||||||
|
|
||||||
friend class PdmUiTableViewDelegate;
|
friend class PdmUiTableViewDelegate;
|
||||||
QWidget* getEditorWidgetAndTransferOwnership(QWidget* parent, const QModelIndex &index);
|
QWidget* getEditorWidgetAndTransferOwnership(QWidget* parent, const QModelIndex &index);
|
||||||
|
|||||||
Reference in new issue
Block a user