Skip to content

Commit

Permalink
Merge pull request #37 from KAHR-Alpha/bugfix/load_script_crash
Browse files Browse the repository at this point in the history
Bugfix/load script crash
  • Loading branch information
KAHR-Alpha authored Apr 20, 2024
2 parents 412fb96 + 274dde5 commit 97a5057
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ endfunction()

set(CPACK_PACKAGE_VERSION_MAJOR 0)
set(CPACK_PACKAGE_VERSION_MINOR 14)
set(CPACK_PACKAGE_VERSION_PATCH 1)
set(CPACK_PACKAGE_VERSION_PATCH 2)

set(TASK "Build CLI" CACHE STRING "What to do")
set_property(CACHE TASK PROPERTY STRINGS "Build CLI" "Build CLI+GUI")
Expand Down
22 changes: 21 additions & 1 deletion src/GUI/Materials/gui_material_library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,11 +640,31 @@ GUI::Material* MaterialsLib::load_script(std::filesystem::path const &path)
}

for(std::size_t i=0;i<data.size();i++)
if(std::filesystem::equivalent(path,data[i]->script_path))
{
if(data[i]->script_path.empty()) continue;

std::error_code error;
if(!std::filesystem::exists(data[i]->script_path, error))
{
if(error)
{
wxMessageBox(data[i]->script_path.generic_string()+": "+error.message(), "File access error");
}

continue;
}

if(std::filesystem::equivalent(path,data[i]->script_path, error))
{
wxMessageBox("Duplicate material","Error");
return nullptr;
}

if(error)
{
wxMessageBox(data[i]->script_path.generic_string()+": "+error.message(), "File access error");
}
}

GUI::Material *new_data=new GUI::Material;
new_data->type=MatType::SCRIPT;
Expand Down

0 comments on commit 97a5057

Please sign in to comment.