Skip to content

Commit 5528da7

Browse files
committed
Fix saving assemblies when opened with a relative path on the command
... 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.
1 parent f2a2e23 commit 5528da7

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/file.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ void SolveSpaceUI::SaveUsingTable(const Platform::Path &filename, int type) {
246246

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

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

0 commit comments

Comments
 (0)