File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change 17
17
#include < QRegularExpression>
18
18
#include < QFileInfo>
19
19
#include < QDir>
20
+ #include < QSet>
20
21
21
22
QString QgsFileUtils::representFileSize ( qint64 bytes )
22
23
{
@@ -106,12 +107,17 @@ QString QgsFileUtils::findClosestExistingPath( const QString &path )
106
107
else
107
108
currentPath = QDir ( path );
108
109
110
+ QSet< QString > visited;
109
111
while ( !currentPath.exists () )
110
112
{
111
113
const QString parentPath = QDir::cleanPath ( currentPath.path () + QStringLiteral ( " /.." ) );
114
+ if ( visited.contains ( parentPath ) )
115
+ return QString (); // break circular links
116
+
112
117
if ( parentPath.isEmpty () || parentPath == ' .' )
113
118
return QString ();
114
119
currentPath = QDir ( parentPath );
120
+ visited << parentPath;
115
121
}
116
122
117
123
const QString res = QDir::cleanPath ( currentPath.path () );
You can’t perform that action at this time.
0 commit comments