From 18eb018a1465ee76b083d7005dc28ff67506b341 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Wed, 26 Aug 2020 16:26:46 +0800 Subject: [PATCH] App: fix PropertyXLink handling on symlink file path --- src/App/PropertyLinks.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/App/PropertyLinks.cpp b/src/App/PropertyLinks.cpp index a1d9321aa5..1ad3572c52 100644 --- a/src/App/PropertyLinks.cpp +++ b/src/App/PropertyLinks.cpp @@ -2440,7 +2440,10 @@ bool PropertyLinkSubList::adjustLink(const std::set &inLis // Key on absolute path. // Because of possible symbolic links, multiple entry may refer to the same -// file. We use QFileInfo::canonicalPath to resolve that. +// file. We used to rely on QFileInfo::canonicalFilePath to resolve it, but +// has now been changed to simply use the absoluteFilePath(), and rely on user +// to be aware of possible duplicated file location. The reason being that +// some user (especially Linux user) use symlink to organize file tree. typedef std::map DocInfoMap; DocInfoMap _DocInfoMap; @@ -2550,16 +2553,20 @@ public: if (path.startsWith(QLatin1String("https://"))) return path; - else - return QFileInfo(path).canonicalFilePath(); + else { + // return QFileInfo(path).canonicalFilePath(); + return QFileInfo(path).absoluteFilePath(); + } } QString getFullPath() const { QString path = myPos->first; if (path.startsWith(QLatin1String("https://"))) return path; - else - return QFileInfo(myPos->first).canonicalFilePath(); + else { + // return QFileInfo(myPos->first).canonicalFilePath(); + return QFileInfo(myPos->first).absoluteFilePath(); + } } const char *filePath() const { @@ -2683,7 +2690,8 @@ public: if(&doc!=pcDoc) return; QFileInfo info(myPos->first); - QString path(info.canonicalFilePath()); + // QString path(info.canonicalFilePath()); + QString path(info.absoluteFilePath()); const char *filename = doc.getFileName(); QString docPath(getFullPath(filename));