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

Fix Paths for handling XaoS Images #176

Merged
merged 2 commits into from
Jun 27, 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
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