diff --git a/CHANGELOG.txt b/CHANGELOG.txt index a9f24100..b4d6c5e3 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,6 @@ [v1.5.2] + fix a critical bug that would cause SHADERed to not store proper texture paths in project files ++ fix a bug that would cause SHADERed to crash on creating cubemaps + fix a bug that caused the geometry shader file dialog to be unresponsive + fix a bug that would crash SHADERed when a project file is referencing an texture that doesn't exist diff --git a/src/SHADERed/Objects/ObjectManager.cpp b/src/SHADERed/Objects/ObjectManager.cpp index 472c6a58..985d6b29 100644 --- a/src/SHADERed/Objects/ObjectManager.cpp +++ b/src/SHADERed/Objects/ObjectManager.cpp @@ -146,7 +146,7 @@ namespace ed { int nrChannels = 0; if (!isDDS) { - stbi_load(path.c_str(), &w, &h, &nrChannels, 0); + data = stbi_load(path.c_str(), &w, &h, &nrChannels, 0); } else { ddsImage = dds_load_from_file(path.c_str()); diff --git a/src/SHADERed/Objects/ProjectParser.cpp b/src/SHADERed/Objects/ProjectParser.cpp index 7f11ae5e..403caf28 100644 --- a/src/SHADERed/Objects/ProjectParser.cpp +++ b/src/SHADERed/Objects/ProjectParser.cpp @@ -593,12 +593,8 @@ namespace ed { bool isKeyboardTexture = (item->Type == ObjectType::KeyboardTexture); std::string texOutPath = item->Name; - if ((isTexture && !isKeyboardTexture) || isAudio) { - if (std::filesystem::path(item->Name).is_absolute()) - texOutPath = GetRelativePath(item->Name); - else - texOutPath = GetRelativePath(std::filesystem::absolute(std::filesystem::path(oldProjectPath) / item->Name).string()); - } + if ((isTexture && !isKeyboardTexture) || isAudio) + texOutPath = GetTexturePath(item->Name, oldProjectPath); std::string typeName = "texture"; if (isBuffer) typeName = "buffer"; @@ -635,12 +631,12 @@ namespace ed { textureNode.append_attribute("cube").set_value(isCube); - textureNode.append_attribute("left").set_value(texmaps[0].c_str()); - textureNode.append_attribute("top").set_value(texmaps[1].c_str()); - textureNode.append_attribute("front").set_value(texmaps[2].c_str()); - textureNode.append_attribute("bottom").set_value(texmaps[3].c_str()); - textureNode.append_attribute("right").set_value(texmaps[4].c_str()); - textureNode.append_attribute("back").set_value(texmaps[5].c_str()); + textureNode.append_attribute("left").set_value(GetTexturePath(texmaps[0], oldProjectPath).c_str()); + textureNode.append_attribute("top").set_value(GetTexturePath(texmaps[1], oldProjectPath).c_str()); + textureNode.append_attribute("front").set_value(GetTexturePath(texmaps[2], oldProjectPath).c_str()); + textureNode.append_attribute("bottom").set_value(GetTexturePath(texmaps[3], oldProjectPath).c_str()); + textureNode.append_attribute("right").set_value(GetTexturePath(texmaps[4], oldProjectPath).c_str()); + textureNode.append_attribute("back").set_value(GetTexturePath(texmaps[5], oldProjectPath).c_str()); } if ((isTexture && !isKeyboardTexture) || isTexture3D) { @@ -663,7 +659,7 @@ namespace ed { ImageObject* iobj = item->Image; if (iobj->DataPath[0] != 0) - textureNode.append_attribute("data").set_value(iobj->DataPath); + textureNode.append_attribute("data").set_value(GetTexturePath(iobj->DataPath, oldProjectPath).c_str()); textureNode.append_attribute("width").set_value(iobj->Size.x); textureNode.append_attribute("height").set_value(iobj->Size.y); @@ -1045,6 +1041,13 @@ namespace ed { { return std::filesystem::exists(GetProjectPath(str)); } + std::string ProjectParser::GetTexturePath(const std::string& texPath, const std::string& oldProjectPath) + { + if (std::filesystem::path(texPath).is_absolute()) + return GetRelativePath(texPath); + else + return GetRelativePath(std::filesystem::absolute(std::filesystem::path(oldProjectPath) / texPath).string()); + } void ProjectParser::ResetProjectDirectory() { m_file = ""; diff --git a/src/SHADERed/Objects/ProjectParser.h b/src/SHADERed/Objects/ProjectParser.h index 6fa9695d..72c56862 100644 --- a/src/SHADERed/Objects/ProjectParser.h +++ b/src/SHADERed/Objects/ProjectParser.h @@ -53,6 +53,7 @@ namespace ed { std::string GetRelativePath(const std::string& to); std::string GetProjectPath(const std::string& projectFile); bool FileExists(const std::string& file); + std::string GetTexturePath(const std::string& texPath, const std::string& oldProjectPath); void ResetProjectDirectory(); inline void SetProjectDirectory(const std::string& path) { m_projectPath = path; }