make $$relative_path() minimize already relative paths
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>
Mon, 6 Aug 2012 18:44:10 +0000 (20:44 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 7 Aug 2012 14:40:07 +0000 (16:40 +0200)
QDir::relativeFilePath() doesn't do anything if the path is already
relative, so make it absolute first to force a re-calculation.

the cleanPath() is gone, as relativeFilePath() already does that.

Change-Id: I8f4d0d839db3fe99a608f70916b4b5bd52c56535
Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
qmake/project.cpp

index 3379f45..7a80cc6 100644 (file)
@@ -2727,12 +2727,13 @@ QMakeProject::doProjectExpand(QString func, QList<QStringList> args_list,
                                    .absoluteFilePath(args.at(0)));
         break;
     case E_RELATIVE_PATH:
-        if (args.count() > 2)
+        if (args.count() > 2) {
             fprintf(stderr, "%s:%d relative_path(path[, base]) requires one or two arguments.\n",
                     parser.file.toLatin1().constData(), parser.line_no);
-        else
-            ret += QDir::cleanPath(QDir(args.count() > 1 ? args.at(1) : QString())
-                                   .relativeFilePath(args.at(0)));
+        } else {
+            QDir baseDir(args.count() > 1 ? args.at(1) : QString());
+            ret += baseDir.relativeFilePath(baseDir.absoluteFilePath(args.at(0)));
+        }
         break;
     case E_CLEAN_PATH:
         if (args.count() != 1)