Cycles: Fix problems in the IES loader when rendering with no file selected

This commit is contained in:
Lukas Stockner 2018-05-27 17:14:01 +02:00
parent 56254a42e0
commit edce44d693
4 changed files with 12 additions and 3 deletions

View File

@ -827,6 +827,9 @@ static ShaderNode *add_node(Scene *scene,
break;
case BL::ShaderNodeTexIES::mode_INTERNAL:
ies->ies = get_text_datablock_content(b_ies_node.ies().ptr);
if(ies->ies.empty()) {
ies->ies = "\n";
}
break;
}
node = ies;

View File

@ -468,7 +468,7 @@ static inline string blender_absolute_path(BL::BlendData& b_data,
return path;
}
static inline string get_text_datablock_content(const PointerRNA&& ptr)
static inline string get_text_datablock_content(const PointerRNA& ptr)
{
if(ptr.data == NULL) {
return "";

View File

@ -891,8 +891,10 @@ void LightManager::tag_update(Scene * /*scene*/)
int LightManager::add_ies_from_file(ustring filename)
{
string content;
/* If the file can't be opened, call with an empty string */
path_read_text(filename.c_str(), content);
/* If the file can't be opened, call with an empty line */
if(filename.empty() || !path_read_text(filename.c_str(), content)) {
content == "\n";
}
return add_ies(ustring(content));
}

View File

@ -109,6 +109,10 @@ public:
bool IESFile::parse(ustring ies)
{
if(ies.empty()) {
return false;
}
IESTextParser parser(ies);
if(parser.eof()) {
return false;