Skip to content

Commit

Permalink
Merge pull request #176 from kanurag94/png-patch
Browse files Browse the repository at this point in the history
Fix Paths for handling XaoS Images
  • Loading branch information
kovzol authored Jun 27, 2020
2 parents 1b0f816 + 9d3da98 commit 47aabbd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/ui-hlp/ui_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,10 @@ void uih_loadpngfile(struct uih_context *c, xio_constpath d)
uih_error(c, TR("Error", "Could not open image"));
return;
}
uih_loadfile(c, ".xaos_temp.xpf");
char filepath[4096];
strcpy(filepath, xio_getdirectory(d));
strcat(filepath, ".xaos_temp.xpf");
uih_loadfile(c, filepath);
if(c->errstring == NULL) {
char s[256];
sprintf(s, TR("Message", "File %s loaded."), d);
Expand All @@ -658,7 +661,10 @@ void uih_savepngfile(struct uih_context *c, xio_constpath d)
return;
}
c->errstring = NULL;
uih_saveposfile(c, ".xaos_temp.xpf");
char filepath[4096];
strcpy(filepath, xio_getdirectory(d));
strcat(filepath, ".xaos_temp.xpf");
uih_saveposfile(c, filepath);
s = uih_save(c, d);
if (s != NULL)
uih_error(c, s);
Expand Down
10 changes: 8 additions & 2 deletions src/ui/image_qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ int xtextcharw(struct image */*image*/, void *font, const char c)
const char *writepng(xio_constpath filename, const struct image *image)
{
QImage *qimage = reinterpret_cast<QImage **>(image->data)[image->currimage];
QFile f(".xaos_temp.xpf");
char filepath[4096];
strcpy(filepath, xio_getdirectory(filename));
strcat(filepath, ".xaos_temp.xpf");
QFile f(filepath);
if(!f.open(QFile::ReadOnly |
QFile::Text))
{
Expand All @@ -90,7 +93,10 @@ const char *readpng(xio_constpath filename)
if(xpf_chunk.isNull() || xpf_chunk.isEmpty()) {
return "Not valid image";
}
QFile f(".xaos_temp.xpf");
char filepath[4096];
strcpy(filepath, xio_getdirectory(filename));
strcat(filepath, ".xaos_temp.xpf");
QFile f(filepath);
if(!f.open(QFile::WriteOnly |
QFile::Text))
{
Expand Down

0 comments on commit 47aabbd

Please sign in to comment.