TextEditor: Utils: Do not use invalid regular expressions

Having a search inside a document and switching the find options
to use regular expressions may end up in lots of warnings
regarding using an invalid expression for a match call.
Check beforehand to avoid this.

Change-Id: Ia929090ae3910ff3fa87b57a5718293d2b6ccd04
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2020-06-19 12:08:17 +02:00
committed by David Schulz
parent 4a8b3268dd
commit d47f8eaff2
2 changed files with 5 additions and 1 deletions

View File

@@ -251,6 +251,10 @@ QRegularExpressionMatch FileSearchRegExp::doGuardedMatch(const QString &line, in
void FileSearchRegExp::operator()(QFutureInterface<FileSearchResultList> &futureInterface, void FileSearchRegExp::operator()(QFutureInterface<FileSearchResultList> &futureInterface,
const FileIterator::Item &item) const const FileIterator::Item &item) const
{ {
if (!expression.isValid()) {
futureInterface.cancel();
return;
}
if (futureInterface.isCanceled()) if (futureInterface.isCanceled())
return; return;
futureInterface.setProgressRange(0, 1); futureInterface.setProgressRange(0, 1);

View File

@@ -4251,7 +4251,7 @@ void TextEditorWidgetPrivate::paintSearchResultOverlay(const PaintEventData &dat
QPainter &painter) const QPainter &painter) const
{ {
m_searchResultOverlay->clear(); m_searchResultOverlay->clear();
if (m_searchExpr.pattern().isEmpty()) if (m_searchExpr.pattern().isEmpty() || !m_searchExpr.isValid())
return; return;
const int margin = 5; const int margin = 5;