Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show error message on non xaos pngs #167

Merged
merged 1 commit into from
Jun 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ui-hlp/ui_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ void uih_loadpngfile(struct uih_context *c, xio_constpath d)
}
const char *s = readpng(d);
if(s != NULL) {
uih_error(c, TR("Error", "Could not open Image"));
uih_error(c, TR("Error", "Could not open image"));
return;
}
uih_loadfile(c, ".xaos_temp.xpf");
Expand Down
5 changes: 5 additions & 0 deletions src/ui/image_qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const char *writepng(xio_constpath filename, const struct image *image)
QFile::Text))
{
qDebug()<<"Could not open the file for reading";
qDebug()<<"Image will be created without xpf data";
}
QTextStream in(&f);
QString xpf_chunk = in.readAll();
Expand All @@ -86,11 +87,15 @@ const char *readpng(xio_constpath filename)
QImageReader reader(filename);
const QImage xaos_image = reader.read();
QString xpf_chunk = xaos_image.text("Metadata");
if(xpf_chunk.isNull() || xpf_chunk.isEmpty()) {
return "Not valid image";
}
QFile f(".xaos_temp.xpf");
if(!f.open(QFile::WriteOnly |
QFile::Text))
{
qDebug() << " Could not open the file for writing";
return "No file or permission";
}
QTextStream in(&f);
in<<xpf_chunk;
Expand Down