Assert fail on parser in DEBUG mode, when multiparser working at the same time

This commit is contained in:
Roy Qu 2023-02-21 22:40:29 +08:00
parent dc783f70dc
commit c1f8489bfd
2 changed files with 7 additions and 9 deletions

View File

@ -27,6 +27,7 @@
#include <QTime>
static QAtomicInt cppParserCount(0);
CppParser::CppParser(QObject *parent) : QObject(parent),
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
mMutex()
@ -3010,11 +3011,6 @@ void CppParser::handleScope(KeywordType keywordType)
mIndex+=2; // the scope is followed by a ':'
}
#ifdef QT_DEBUG
static int lastIndex=-1;
#endif
bool CppParser::handleStatement()
{
QString funcType,funcName;
@ -3024,8 +3020,8 @@ bool CppParser::handleStatement()
KeywordType keywordType;
#ifdef QT_DEBUG
// qDebug()<<lastIndex<<mIndex;
Q_ASSERT(mIndex>=lastIndex);
lastIndex=mIndex;
Q_ASSERT(mIndex>=mLastIndex);
mLastIndex=mIndex;
#endif
if (mIndex >= idx2) {
@ -3826,7 +3822,7 @@ void CppParser::internalParse(const QString &fileName)
// mTokenizer.dumpTokens(QString("r:\\tokens-%1.txt").arg(extractFileName(fileName)));
#endif
#ifdef QT_DEBUG
lastIndex = -1;
mLastIndex = -1;
#endif
// Process the token list
while(true) {

View File

@ -665,7 +665,9 @@ private:
bool mParsing;
QHash<QString,PStatementList> mNamespaces; // namespace and the statements in its scope
QSet<QString> mInlineNamespaces;
#ifdef QT_DEBUG
int mLastIndex;
#endif
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
QRecursiveMutex mMutex;
#else