1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-01 04:45:34 +00:00

deal with empty and invalid referenceable ID fields

This commit is contained in:
Marc Zinnschlag 2014-03-21 12:44:06 +01:00
parent 1a9df4bc56
commit 58daf52a67
2 changed files with 14 additions and 3 deletions

View file

@ -30,9 +30,16 @@ void CSVRender::PreviewWidget::setModel()
{ {
mObject.setNull(); mObject.setNull();
int column = mData.getReferenceables().findColumnIndex (CSMWorld::Columns::ColumnId_Model); if (mReferenceableId.empty())
return;
int row = mData.getReferenceables().getIndex (mReferenceableId); int column =
mData.getReferenceables().findColumnIndex (CSMWorld::Columns::ColumnId_Model);
int row = mData.getReferenceables().searchId (mReferenceableId);
if (row==-1)
return;
QVariant value = mData.getReferenceables().getData (row, column); QVariant value = mData.getReferenceables().getData (row, column);
@ -142,6 +149,7 @@ void CSVRender::PreviewWidget::ReferenceDataChanged (const QModelIndex& topLeft,
if (index.column()>=topLeft.column() && index.column()<=bottomRight.row()) if (index.column()>=topLeft.column() && index.column()<=bottomRight.row())
{ {
mReferenceableId = references.data (index).toString().toUtf8().constData(); mReferenceableId = references.data (index).toString().toUtf8().constData();
/// \todo update title
setModel(); setModel();
} }

View file

@ -21,7 +21,10 @@ CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDo
std::string referenceableId = std::string referenceableId =
document.getData().getReferences().getRecord (id.getId()).get().mRefID; document.getData().getReferences().getRecord (id.getId()).get().mRefID;
setWindowTitle (("Preview: Reference to " + referenceableId).c_str()); if (referenceableId.empty())
setWindowTitle ("Preview: Reference to <nothing>");
else
setWindowTitle (("Preview: Reference to " + referenceableId).c_str());
mScene = mScene =
new CSVRender::PreviewWidget (document.getData(), referenceableId, id.getId(), this); new CSVRender::PreviewWidget (document.getData(), referenceableId, id.getId(), this);