Fixed some potential crashes in ImageComponent caused by invalid theme configuration.

This commit is contained in:
Leon Styhre 2022-09-01 17:35:40 +02:00
parent c03d50e0e5
commit 819d1b0341

View file

@ -146,10 +146,15 @@ void ImageComponent::setImage(const std::string& path, bool tile)
if (!mForceLoad && (path[0] == ':') && (path[1] == '/')) { if (!mForceLoad && (path[0] == ':') && (path[1] == '/')) {
mDynamic = false; mDynamic = false;
} }
else if (Utils::FileSystem::isDirectory(path)) {
LOG(LogError) << "ImageComponent: Path is a directory and not a file: \"" << path << "\"";
return;
}
const bool isScalable {path != "" ? Utils::String::toLower(path.substr( const bool isScalable {
path.size() - 4, std::string::npos)) == ".svg" : (path != "" && path.length() > 4) ?
false}; Utils::String::toLower(path.substr(path.size() - 4, std::string::npos)) == ".svg" :
false};
// Create an initial blank texture if needed. // Create an initial blank texture if needed.
if (path.empty() || !ResourceManager::getInstance().fileExists(path)) { if (path.empty() || !ResourceManager::getInstance().fileExists(path)) {