aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2017-04-26 11:22:20 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2017-04-26 10:51:58 +0000
commitcca93156a704711f7b9eec6603688e05af40650f (patch)
tree3e272e30c4fc9056087b4843cafd223f95ffd619
parent4d80579c49a40cbbb24bef2cb4cbe4520b7b4ca9 (diff)
Handle recursive typesystem includes
For QtMultimedia, the QMediaPlayer::setVideoOutput() overloads require including QtMultimediaWidgets' typesystem to make QVideoWidget known. This caused an endless recursion including QtMultimedia's typesystem. Fix by - ensure modifiedTypesystemFilepath() always returns an absolute path even if the file exists so that it is always matched in m_parsedTypesystemFiles - Insert current file into m_parsedTypesystemFiles at the beginning of parseFile() to detect recursion early on. Task-number: PYSIDE-487 Change-Id: I7110c9f1bf144b82a14282e94b894bfb0522ba58 Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r--ApiExtractor/typedatabase.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/ApiExtractor/typedatabase.cpp b/ApiExtractor/typedatabase.cpp
index 5cb255094..55170d7c1 100644
--- a/ApiExtractor/typedatabase.cpp
+++ b/ApiExtractor/typedatabase.cpp
@@ -383,14 +383,16 @@ bool TypeDatabase::isSuppressedWarning(const QString& s) const
QString TypeDatabase::modifiedTypesystemFilepath(const QString& tsFile) const
{
- if (!QFile::exists(tsFile)) {
- int idx = tsFile.lastIndexOf(QLatin1Char('/'));
- QString fileName = idx >= 0 ? tsFile.right(tsFile.length() - idx - 1) : tsFile;
- foreach (const QString &path, m_typesystemPaths) {
- QString filepath(path + QLatin1Char('/') + fileName);
- if (QFile::exists(filepath))
- return filepath;
- }
+ const QFileInfo tsFi(tsFile);
+ if (tsFi.isAbsolute()) // No point in further lookups
+ return tsFi.absoluteFilePath();
+ if (tsFi.isFile()) // Make path absolute
+ return tsFi.absoluteFilePath();
+ const QString fileName = tsFi.fileName();
+ foreach (const QString &path, m_typesystemPaths) {
+ const QFileInfo fi(path + QLatin1Char('/') + fileName);
+ if (fi.isFile())
+ return fi.absoluteFilePath();
}
return tsFile;
}
@@ -401,13 +403,17 @@ bool TypeDatabase::parseFile(const QString &filename, bool generate)
if (m_parsedTypesystemFiles.contains(filepath))
return m_parsedTypesystemFiles[filepath];
+ m_parsedTypesystemFiles[filepath] = true; // Prevent recursion when including self.
+
QFile file(filepath);
if (!file.exists()) {
+ m_parsedTypesystemFiles[filepath] = false;
qCWarning(lcShiboken).noquote().nospace()
<< "Can't find " << filename << ", typesystem paths: " << m_typesystemPaths.join(QLatin1String(", "));
return false;
}
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ m_parsedTypesystemFiles[filepath] = false;
qCWarning(lcShiboken).noquote().nospace()
<< "Can't open " << QDir::toNativeSeparators(filename) << ": " << file.errorString();
return false;