diff --git a/src/file.cpp b/src/file.cpp index b1b661b..78308ae 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -255,7 +255,10 @@ void SolveSpace::SaveUsingTable(int type) { bool SolveSpace::SaveToFile(char *filename) { // Make sure all the entities are regenerated up to date, since they - // will be exported. + // will be exported. We reload the imported files because that rewrites + // the impFileRel for our possibly-new filename. + SS.later.showTW = true; + SS.ReloadAllImported(); SS.GenerateAll(0, INT_MAX); fh = fopen(filename, "wb"); diff --git a/src/solvespace.cpp b/src/solvespace.cpp index 78caa55..68ec7ac 100644 --- a/src/solvespace.cpp +++ b/src/solvespace.cpp @@ -319,19 +319,22 @@ void SolveSpace::AddToRecentList(char *file) { } bool SolveSpace::GetFilenameAndSave(bool saveAs) { + char prevSaveFile[MAX_PATH]; + strcpy(prevSaveFile, saveFile); - char newFile[MAX_PATH]; - strcpy(newFile, saveFile); - if(saveAs || strlen(newFile)==0) { - if(!GetSaveFile(newFile, SLVS_EXT, SLVS_PATTERN)) return false; + if(saveAs || strlen(saveFile)==0) { + if(!GetSaveFile(saveFile, SLVS_EXT, SLVS_PATTERN)) return false; + // need to get new filename directly into saveFile, since that + // determines impFileRel path } - if(SaveToFile(newFile)) { - AddToRecentList(newFile); - strcpy(saveFile, newFile); + if(SaveToFile(saveFile)) { + AddToRecentList(saveFile); unsaved = false; return true; } else { + // don't store an invalid save filename + strcpy(saveFile, prevSaveFile); return false; } } diff --git a/src/util.cpp b/src/util.cpp index f5e2b12..c64baae 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -60,7 +60,8 @@ void MakePathRelative(const char *basep, char *pathp) for(i = 0; i < sections; i++) { strcat(out, "../"); } - strcat(out, path+com); + // comparison is case-insensitive, but output preserves input case + strcat(out, pathp+com); strcpy(pathp, out); }