From d47f8eaff2a44ff4c6e79306d04559266a3db644 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Fri, 19 Jun 2020 12:08:17 +0200 Subject: [PATCH] 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 --- src/libs/utils/filesearch.cpp | 4 ++++ src/plugins/texteditor/texteditor.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libs/utils/filesearch.cpp b/src/libs/utils/filesearch.cpp index 03aa1cf9b20..4af8079adf0 100644 --- a/src/libs/utils/filesearch.cpp +++ b/src/libs/utils/filesearch.cpp @@ -251,6 +251,10 @@ QRegularExpressionMatch FileSearchRegExp::doGuardedMatch(const QString &line, in void FileSearchRegExp::operator()(QFutureInterface &futureInterface, const FileIterator::Item &item) const { + if (!expression.isValid()) { + futureInterface.cancel(); + return; + } if (futureInterface.isCanceled()) return; futureInterface.setProgressRange(0, 1); diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 397281b8b5e..59617e4b6c7 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -4251,7 +4251,7 @@ void TextEditorWidgetPrivate::paintSearchResultOverlay(const PaintEventData &dat QPainter &painter) const { m_searchResultOverlay->clear(); - if (m_searchExpr.pattern().isEmpty()) + if (m_searchExpr.pattern().isEmpty() || !m_searchExpr.isValid()) return; const int margin = 5;