diff options
author | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2018-10-19 10:20:27 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2018-10-31 10:38:27 +0000 |
commit | d52ac9a7084df220a5349468703c11cc1c0794c4 (patch) | |
tree | edf93dd6c68e9e3614e728a1e1a08456381c76db /src/libs | |
parent | 91ed30ffac8f218f13a6d01d77f7e6398749cb67 (diff) | |
download | qt-creator-d52ac9a7084df220a5349468703c11cc1c0794c4.tar.gz |
Clang: Fix unresolved #includes for ui_*.h headers
...with an extra parse.
Previously, the creation of an e.g. "Qt Widgets Application" from the
wizard could show code model errors in mainwindow.cpp. Depending on
timing issues, the first error is either
1. 'ui_mainwindow.h' file not found (QTCREATORBUG-15187)
The parse happened before the in-memory ui_mainwindow.h was
generated by uic. The file system watcher can't help here as the
#include was not resolved successfully. And libclang's reparse does
not handle this case (it would need to remember all failed #include
stats...).
==> Detect this case with the help of the include paths and trigger
a full parse.
2. or: allocation of incomplete type... (QTCREATORBUG-15187)
The parse happened after the generation of the in-memory
ui_mainwindow.h, but before the clangbackend received the unsaved
file.
==> Fix this by also writing the content of the unsaved file to our
behind-the-scenes-created ui_mainwindow.h.
Fixes: QTCREATORBUG-15187
Fixes: QTCREATORBUG-17002
Change-Id: I4f3a81adaa3d604746977a402c29f83fbc5b0e44
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/clangsupport/filecontainer.cpp | 1 | ||||
-rw-r--r-- | src/libs/clangsupport/filecontainer.h | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/libs/clangsupport/filecontainer.cpp b/src/libs/clangsupport/filecontainer.cpp index 7f95e4b1d4..0f6f8288c9 100644 --- a/src/libs/clangsupport/filecontainer.cpp +++ b/src/libs/clangsupport/filecontainer.cpp @@ -36,6 +36,7 @@ QDebug operator<<(QDebug debug, const FileContainer &container) debug.nospace() << "FileContainer(" << container.filePath << ", " << container.compilationArguments << ", " + << container.headerPaths << ", " << container.documentRevision << ", " << container.textCodecName; diff --git a/src/libs/clangsupport/filecontainer.h b/src/libs/clangsupport/filecontainer.h index 16beff0bac..4f9595f5ba 100644 --- a/src/libs/clangsupport/filecontainer.h +++ b/src/libs/clangsupport/filecontainer.h @@ -53,11 +53,13 @@ public: FileContainer(const Utf8String &filePath, const Utf8StringVector &compilationArguments, + const Utf8StringVector &headerPaths, const Utf8String &unsavedFileContent = Utf8String(), bool hasUnsavedFileContent = false, quint32 documentRevision = 0) : filePath(filePath), compilationArguments(compilationArguments), + headerPaths(headerPaths), unsavedFileContent(unsavedFileContent), documentRevision(documentRevision), hasUnsavedFileContent(hasUnsavedFileContent) @@ -66,9 +68,11 @@ public: FileContainer(const Utf8String &filePath, const Utf8StringVector &compilationArguments, + const Utf8StringVector &headerPaths, quint32 documentRevision) : filePath(filePath), compilationArguments(compilationArguments), + headerPaths(headerPaths), documentRevision(documentRevision), hasUnsavedFileContent(false) { @@ -78,6 +82,7 @@ public: { out << container.filePath; out << container.compilationArguments; + out << container.headerPaths; out << container.unsavedFileContent; out << container.textCodecName; out << container.documentRevision; @@ -90,6 +95,7 @@ public: { in >> container.filePath; in >> container.compilationArguments; + in >> container.headerPaths; in >> container.unsavedFileContent; in >> container.textCodecName; in >> container.documentRevision; @@ -106,6 +112,7 @@ public: public: Utf8String filePath; Utf8StringVector compilationArguments; + Utf8StringVector headerPaths; Utf8String unsavedFileContent; Utf8String textCodecName; quint32 documentRevision = 0; |