From 215b8e4537f36cf1132f2d6f0e1b1f7eeee7dfbf Mon Sep 17 00:00:00 2001 From: whitequark Date: Mon, 6 Jun 2016 16:05:37 +0000 Subject: [PATCH] Unbreak importing files in the same directory as current file. This commit fixes a bug introduced in commit 0d7aa0a1. --- src/file.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/file.cpp b/src/file.cpp index ee4f3a23..d9545157 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -804,17 +804,20 @@ bool SolveSpaceUI::ReloadAllImported(bool canCancel) g->linkFile = newPath; } - std::string rel = PathSepUNIXToPlatform(g->linkFileRel); - std::string fromRel = MakePathAbsolute(SS.saveFile, rel); - FILE *test = ssfopen(fromRel, "rb"); - if(test) { - fclose(test); - // Okay, exists; update the absolute path. - g->linkFile = fromRel; - } else { - // It doesn't exist. Perhaps the file was moved but the tree wasn't, and we - // can use the absolute filename to get us back. The relative path will be - // updated below. + // In a newly created group we only have an absolute path. + if(!g->linkFileRel.empty()) { + std::string rel = PathSepUNIXToPlatform(g->linkFileRel); + std::string fromRel = MakePathAbsolute(SS.saveFile, rel); + FILE *test = ssfopen(fromRel, "rb"); + if(test) { + fclose(test); + // Okay, exists; update the absolute path. + g->linkFile = fromRel; + } else { + // It doesn't exist. Perhaps the file was moved but the tree wasn't, and we + // can use the absolute filename to get us back. The relative path will be + // updated below. + } } try_load_file: