Skip to content
Snippets Groups Projects
Commit cc34b7c9 authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

Assert for non-existing material is replaced with throw.

parent 2fb4253a
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#include "SampleModel.h" #include "SampleModel.h"
#include "LayerItem.h" #include "LayerItem.h"
#include "MultiLayerItem.h" #include "MultiLayerItem.h"
#include "MaterialProperty.h"
#include "MaterialSvc.h"
SampleModel::SampleModel(QObject *parent) SampleModel::SampleModel(QObject *parent)
: SessionModel(SessionXML::SampleModelTag, parent) : SessionModel(SessionXML::SampleModelTag, parent)
...@@ -55,8 +57,14 @@ void SampleModel::exploreForMaterials(const QModelIndex &parentIndex) ...@@ -55,8 +57,14 @@ void SampleModel::exploreForMaterials(const QModelIndex &parentIndex)
if (SessionItem *item = itemForIndex(itemIndex)) { if (SessionItem *item = itemForIndex(itemIndex)) {
if (item->modelType() == Constants::LayerType if (item->modelType() == Constants::LayerType
|| item->modelType() == Constants::ParticleType) { || item->modelType() == Constants::ParticleType) {
// we pretend here that MaterialProperty changed to update IView colors MaterialProperty material_property =
item->getItem(LayerItem::P_MATERIAL)->emitDataChanged(); item->getItemValue(LayerItem::P_MATERIAL).value<MaterialProperty>();
if(!MaterialSvc::getMaterial(material_property)) {
item->setItemValue(LayerItem::P_MATERIAL, MaterialProperty().getVariant());
} else {
// we pretend here that MaterialProperty changed to update IView colors
item->getItem(LayerItem::P_MATERIAL)->emitDataChanged();
}
} }
} }
exploreForMaterials(itemIndex); exploreForMaterials(itemIndex);
......
...@@ -66,6 +66,10 @@ MaterialUtils::createDomainMaterial(const MaterialProperty &material_property) ...@@ -66,6 +66,10 @@ MaterialUtils::createDomainMaterial(const MaterialProperty &material_property)
{ {
MaterialItem *materialItem MaterialItem *materialItem
= MaterialSvc::getMaterial(material_property); = MaterialSvc::getMaterial(material_property);
Q_ASSERT(materialItem);
if(!materialItem)
throw GUIHelpers::Error("MaterialUtils::createDomainMaterial() -> Error. Can't create "
"material with name '"+material_property.getName()+"'.");
return materialItem->createMaterial(); return materialItem->createMaterial();
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment