Skip to content

Commit

Permalink
Use fcsmart for capturing loadText data.
Browse files Browse the repository at this point in the history
  • Loading branch information
gijsbers committed Oct 12, 2023
1 parent 9980833 commit 4f8ccbb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/iceview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ class FileView: public YDndWindow {
void loadFile() {
mstring ext(path.getExtension().lower());
if (ext == ".xpm" || ext == ".png" || ext == ".svg" ||
ext == ".jpg" || ext == ".jpeg")
ext == ".jpg" || ext == ".jpeg" || ext == ".webp")
{
ref<YImage> image = YImage::load(path);
if (image != null) {
Expand All @@ -651,15 +651,16 @@ class FileView: public YDndWindow {
max(height(), image->height()));
}
}
else printf("Cannot load %s.\n", path.string());
}
else
{
char* buf = path.loadText();
fcsmart buf(path.loadText());
if (buf) {
int len = strlen(buf);
setSize(max(width(), 80 * unsigned(view->getFontWidth())),
max(height(), 30 * unsigned(view->getFontHeight())));
view->setData(buf, len);
view->setData(buf.release(), len);
}
}
}
Expand Down

0 comments on commit 4f8ccbb

Please sign in to comment.