Highlighter: fix crash after closing file

Regular expression rules are tracked inside the progress data to inform
the rule about a finished highlighting process. A cloned rule was not properly
tracked. That results in a rule that tries to untrack itself on
destruction after the progress data has already been deleted.

Task-number: QTCREATORBUG-20247
Change-Id: I007e7afbc16706bc28f89faf91c0b1c5f0bc692a
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2018-04-12 14:41:10 +02:00
parent 8797123128
commit f4594c922f
2 changed files with 9 additions and 1 deletions

View File

@@ -247,6 +247,14 @@ bool RegExprRule::doMatchSucceed(const QString &text,
return false; return false;
} }
RegExprRule *RegExprRule::doClone() const
{
auto clone = new RegExprRule(*this);
if (m_progress)
m_progress->trackRule(clone);
return clone;
}
// Keyword // Keyword
KeywordRule::KeywordRule(const QSharedPointer<HighlightDefinition> &definition) : KeywordRule::KeywordRule(const QSharedPointer<HighlightDefinition> &definition) :
m_overrideGlobal(false), m_overrideGlobal(false),

View File

@@ -124,7 +124,7 @@ private:
virtual bool doMatchSucceed(const QString &text, virtual bool doMatchSucceed(const QString &text,
const int length, const int length,
ProgressData *progress); ProgressData *progress);
virtual RegExprRule *doClone() const { return new RegExprRule(*this); } virtual RegExprRule *doClone() const;
virtual void doReplaceExpressions(const QStringList &captures); virtual void doReplaceExpressions(const QStringList &captures);
virtual void doProgressFinished(); virtual void doProgressFinished();