Skip to content

Commit a31a89a

Browse files
committed
Fix saving assemblies when opened with a relative path on the command line.
When a file containing linked files (an assembly) was opened by passing a relative path to it on the command line; saving it would fail with an error: "This sketch links the sketch '%s'; it can only be saved on the same volume." The problem stems from not `Expand`-ing paths immediately in `main` which was introduced in 3ea8ebf see here for details: solvespace#1474 (comment) The fix is to expand paths to linked files before making them relative to the assembly. Fixes solvespace#1465
1 parent 9fb6ade commit a31a89a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/file.cpp

+2-2
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().RelativeTo(filename.Parent());
249+
Platform::Path relativePath = p->P().Expand(/*fromCurrentDirectory=*/true).RelativeTo(filename.Parent());
250250
ssassert(!relativePath.IsEmpty(), "Cannot relativize path");
251251
fprintf(fh, "%s", relativePath.ToPortable().c_str());
252252
}
@@ -285,7 +285,7 @@ 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.RelativeTo(filename).IsEmpty()) {
288+
if(g.linkFile.Expand(/*fromCurrentDirectory=*/true).RelativeTo(filename).IsEmpty()) {
289289
Error("This sketch links the sketch '%s'; it can only be saved "
290290
"on the same volume.", g.linkFile.raw.c_str());
291291
return false;

0 commit comments

Comments
 (0)