From 58daf52a675da61d87e9fee305e82aa4cf93d664 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 21 Mar 2014 12:44:06 +0100 Subject: [PATCH] deal with empty and invalid referenceable ID fields --- apps/opencs/view/render/previewwidget.cpp | 12 ++++++++++-- apps/opencs/view/world/previewsubview.cpp | 5 ++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/opencs/view/render/previewwidget.cpp b/apps/opencs/view/render/previewwidget.cpp index 9b64cf6f4..94cb7ce6e 100644 --- a/apps/opencs/view/render/previewwidget.cpp +++ b/apps/opencs/view/render/previewwidget.cpp @@ -30,9 +30,16 @@ void CSVRender::PreviewWidget::setModel() { mObject.setNull(); - int column = mData.getReferenceables().findColumnIndex (CSMWorld::Columns::ColumnId_Model); + if (mReferenceableId.empty()) + return; + + int column = + mData.getReferenceables().findColumnIndex (CSMWorld::Columns::ColumnId_Model); - int row = mData.getReferenceables().getIndex (mReferenceableId); + int row = mData.getReferenceables().searchId (mReferenceableId); + + if (row==-1) + return; 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()) { mReferenceableId = references.data (index).toString().toUtf8().constData(); + /// \todo update title setModel(); } diff --git a/apps/opencs/view/world/previewsubview.cpp b/apps/opencs/view/world/previewsubview.cpp index 587af561f..769ff3ddc 100644 --- a/apps/opencs/view/world/previewsubview.cpp +++ b/apps/opencs/view/world/previewsubview.cpp @@ -21,7 +21,10 @@ CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDo std::string referenceableId = document.getData().getReferences().getRecord (id.getId()).get().mRefID; - setWindowTitle (("Preview: Reference to " + referenceableId).c_str()); + if (referenceableId.empty()) + setWindowTitle ("Preview: Reference to "); + else + setWindowTitle (("Preview: Reference to " + referenceableId).c_str()); mScene = new CSVRender::PreviewWidget (document.getData(), referenceableId, id.getId(), this);