From 22ec652ebfb659e8597d4986bd32c3ea82e3e075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Thu, 7 Jun 2018 17:07:09 +0200 Subject: QFINDTESTDATA,Android: fix 'relative to test source' When cross-compiling for Android on Windows the 'relative to test source' option could end up possibly matching with a matching folder in root ('/') because file is a Windows path and the canonicalFilePath of that path is "". Fixes tst_qxmlstream (and possibly others) on Android when Qt is compiled on Windows. Task-number: QTBUG-68596 Change-Id: I378374e41eea80f43680b3941adaa91fa604934a Reviewed-by: Jesus Fernandez Reviewed-by: Thiago Macieira Reviewed-by: Ulf Hermann --- src/testlib/qtestcase.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index adf4b9e1ef..acd676833e 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -2135,8 +2135,9 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co srcdir.setFile(QFile::decodeName(builddir) + QLatin1String("/") + srcdir.filePath()); } - QString candidate = QString::fromLatin1("%1/%2").arg(srcdir.canonicalFilePath(), base); - if (QFileInfo::exists(candidate)) { + const QString canonicalPath = srcdir.canonicalFilePath(); + QString candidate = QString::fromLatin1("%1/%2").arg(canonicalPath, base); + if (!canonicalPath.isEmpty() && QFileInfo::exists(candidate)) { found = candidate; } else if (QTestLog::verboseLevel() >= 2) { -- cgit v1.2.3