Skip to content

Commit

Permalink
Fix saving assemblies when opened with a relative path on the command
Browse files Browse the repository at this point in the history
... line on Linux.

An extra `Expand` for "filename" is needed on Linux when the file was
opened with a relative path on the command line because dialog->RunModal()
in SolveSpaceUI::GetFilenameAndSave will convert the file name to full path
on Windows but not on GTK.
  • Loading branch information
ruevs committed Sep 24, 2024
1 parent f2a2e23 commit 5528da7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void SolveSpaceUI::SaveUsingTable(const Platform::Path &filename, int type) {

case 'P': {
if(!p->P().IsEmpty()) {
Platform::Path relativePath = p->P().Expand(/*fromCurrentDirectory=*/true).RelativeTo(filename.Parent());
Platform::Path relativePath = p->P().Expand(/*fromCurrentDirectory=*/true).RelativeTo(filename.Expand(/*fromCurrentDirectory=*/true).Parent());
ssassert(!relativePath.IsEmpty(), "Cannot relativize path");
fprintf(fh, "%s", relativePath.ToPortable().c_str());
}
Expand Down Expand Up @@ -285,7 +285,12 @@ bool SolveSpaceUI::SaveToFile(const Platform::Path &filename) {
for(Group &g : SK.group) {
if(g.type != Group::Type::LINKED) continue;

if(g.linkFile.Expand(/*fromCurrentDirectory=*/true).RelativeTo(filename).IsEmpty()) {
// Expand for "filename" below is needed on Linux when the file was opened with a relative
// path on the command line. dialog->RunModal() in SolveSpaceUI::GetFilenameAndSave will
// convert the file name to full path on Windows but not on GTK.
if(g.linkFile.Expand(/*fromCurrentDirectory=*/true)
.RelativeTo(filename.Expand(/*fromCurrentDirectory=*/true))
.IsEmpty()) {
Error("This sketch links the sketch '%s'; it can only be saved "
"on the same volume.", g.linkFile.raw.c_str());
return false;
Expand Down

0 comments on commit 5528da7

Please sign in to comment.