Fixed crash when editing character properties
This commit is contained in:
parent
0ca82afbfe
commit
77eb2b3dc5
|
@ -30,7 +30,6 @@ CPropertyDelegate::CPropertyDelegate(QObject *pParent /*= 0*/)
|
|||
, mInRelayWidgetEdit(false)
|
||||
, mEditInProgress(false)
|
||||
, mRelaysBlocked(false)
|
||||
, mUpdatingModel(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -199,8 +198,6 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
|||
|
||||
void CPropertyDelegate::setEditorData(QWidget *pEditor, const QModelIndex &rkIndex) const
|
||||
{
|
||||
if (mUpdatingModel) return;
|
||||
|
||||
BlockRelays(true);
|
||||
mEditInProgress = false; // fixes case where user does undo mid-edit
|
||||
|
||||
|
@ -227,24 +224,39 @@ void CPropertyDelegate::setEditorData(QWidget *pEditor, const QModelIndex &rkInd
|
|||
case eShortProperty:
|
||||
{
|
||||
WIntegralSpinBox *pSpinBox = static_cast<WIntegralSpinBox*>(pEditor);
|
||||
|
||||
if (!pSpinBox->hasFocus())
|
||||
{
|
||||
TShortProperty *pShort = static_cast<TShortProperty*>(pProp);
|
||||
pSpinBox->setValue(pShort->Get());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case eLongProperty:
|
||||
{
|
||||
WIntegralSpinBox *pSpinBox = static_cast<WIntegralSpinBox*>(pEditor);
|
||||
|
||||
if (!pSpinBox->hasFocus())
|
||||
{
|
||||
TLongProperty *pLong = static_cast<TLongProperty*>(pProp);
|
||||
pSpinBox->setValue(pLong->Get());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case eFloatProperty:
|
||||
{
|
||||
WDraggableSpinBox *pSpinBox = static_cast<WDraggableSpinBox*>(pEditor);
|
||||
|
||||
if (!pSpinBox->hasFocus())
|
||||
{
|
||||
TFloatProperty *pFloat = static_cast<TFloatProperty*>(pProp);
|
||||
pSpinBox->setValue(pFloat->Get());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -267,8 +279,13 @@ void CPropertyDelegate::setEditorData(QWidget *pEditor, const QModelIndex &rkInd
|
|||
case eStringProperty:
|
||||
{
|
||||
QLineEdit *pLineEdit = static_cast<QLineEdit*>(pEditor);
|
||||
|
||||
if (!pLineEdit->hasFocus())
|
||||
{
|
||||
TStringProperty *pString = static_cast<TStringProperty*>(pProp);
|
||||
pLineEdit->setText(TO_QSTRING(pString->Get()));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -292,8 +309,13 @@ void CPropertyDelegate::setEditorData(QWidget *pEditor, const QModelIndex &rkInd
|
|||
case eArrayProperty:
|
||||
{
|
||||
WIntegralSpinBox *pSpinBox = static_cast<WIntegralSpinBox*>(pEditor);
|
||||
|
||||
if (!pSpinBox->hasFocus())
|
||||
{
|
||||
CArrayProperty *pArray = static_cast<CArrayProperty*>(pProp);
|
||||
pSpinBox->setValue(pArray->Count());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -323,6 +345,8 @@ void CPropertyDelegate::setEditorData(QWidget *pEditor, const QModelIndex &rkInd
|
|||
WDraggableSpinBox *pSpinBox = static_cast<WDraggableSpinBox*>(pEditor);
|
||||
float Value;
|
||||
|
||||
if (!pSpinBox->hasFocus())
|
||||
{
|
||||
if (pProp->Type() == eVector3Property)
|
||||
{
|
||||
TVector3Property *pVector = static_cast<TVector3Property*>(pProp);
|
||||
|
@ -348,6 +372,7 @@ void CPropertyDelegate::setEditorData(QWidget *pEditor, const QModelIndex &rkInd
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BlockRelays(false);
|
||||
}
|
||||
|
@ -356,7 +381,6 @@ void CPropertyDelegate::setModelData(QWidget *pEditor, QAbstractItemModel* /*pMo
|
|||
{
|
||||
if (!mpModel) return;
|
||||
if (!pEditor) return;
|
||||
mUpdatingModel = true;
|
||||
|
||||
IProperty *pProp = mpModel->PropertyForIndex(rkIndex, false);
|
||||
IPropertyValue *pOldValue = nullptr;
|
||||
|
@ -537,8 +561,6 @@ void CPropertyDelegate::setModelData(QWidget *pEditor, QAbstractItemModel* /*pMo
|
|||
else
|
||||
delete pOldValue;
|
||||
}
|
||||
|
||||
mUpdatingModel = false;
|
||||
}
|
||||
|
||||
bool CPropertyDelegate::eventFilter(QObject *pObject, QEvent *pEvent)
|
||||
|
@ -624,7 +646,7 @@ void CPropertyDelegate::SetCharacterEditorData(QWidget *pEditor, const QModelInd
|
|||
static_cast<QComboBox*>(pEditor)->setCurrentIndex(Params.CharacterIndex());
|
||||
}
|
||||
|
||||
else if (Type == eLongProperty)
|
||||
else if (Type == eLongProperty && !pEditor->hasFocus())
|
||||
{
|
||||
int UnkIndex = (Params.Version() <= eEchoes ? rkIndex.row() - 2 : rkIndex.row() - 1);
|
||||
u32 Value = Params.Unknown(UnkIndex);
|
||||
|
|
|
@ -14,7 +14,6 @@ class CPropertyDelegate : public QStyledItemDelegate
|
|||
bool mInRelayWidgetEdit;
|
||||
mutable bool mEditInProgress;
|
||||
mutable bool mRelaysBlocked;
|
||||
mutable bool mUpdatingModel;
|
||||
|
||||
public:
|
||||
CPropertyDelegate(QObject *pParent = 0);
|
||||
|
|
Loading…
Reference in New Issue