Skip to content

Commit

Permalink
SVG: Fix libromfs cache error
Browse files Browse the repository at this point in the history
  • Loading branch information
xfangfang committed Jul 10, 2023
1 parent e8c0ea6 commit 930cf13
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions wiliwili/source/view/svg_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ SVGImage::SVGImage() {
}

void SVGImage::setImageFromSVGRes(const std::string& value) {
filePath = value;
#ifdef USE_LIBROMFS
if (checkCache("@res/" + value) > 0) return;
filePath = "@res/" + value;
if (checkCache(filePath) > 0) return;
auto image = romfs::get(value);
this->document = lunasvg::Document::loadFromData(
(const char*)image.string().data(), image.size());
if (this->document) {
this->updateBitmap();
} else {
brls::Logger::error("cannot load svg image: {}", value);
brls::Logger::error("setImageFromSVGRes: cannot load svg image: {}",
value);
return;
}

Expand Down Expand Up @@ -63,7 +64,8 @@ void SVGImage::setImageFromSVGFile(const std::string& value) {
if (this->document) {
this->updateBitmap();
} else {
brls::Logger::error("cannot load svg image: {}", value);
brls::Logger::error("setImageFromSVGFile: cannot load svg image: {}",
value);
return;
}

Expand All @@ -81,7 +83,8 @@ void SVGImage::setImageFromSVGString(const std::string& value) {
if (this->document) {
this->updateBitmap();
} else {
brls::Logger::error("cannot load svg image: {}", value);
brls::Logger::error("setImageFromSVGString: cannot load svg image: {}",
value);
}
}

Expand Down

0 comments on commit 930cf13

Please sign in to comment.