From b0e694349143bb88047755a94e808a33725f92ee Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 7 Dec 2022 16:55:38 +0100 Subject: [PATCH] TextEditorWidget: Ensure non-null source is passed to insertFromMimeData Detected by clazy analyzer. The possible context was TextEditorWidget::dropEvent(). In some branches we ensure that mime is not null, but later we call insertFromMimeData() unconditionally. Change-Id: Iee5138bc19d405050eafc9617d3c2ed123b767c7 Reviewed-by: Reviewed-by: David Schulz --- src/plugins/texteditor/texteditor.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 3594493013b..303c5884667 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -7847,7 +7847,7 @@ struct MappedText void TextEditorWidget::insertFromMimeData(const QMimeData *source) { - if (isReadOnly()) + if (!source || isReadOnly()) return; QString text = source->text(); @@ -7857,7 +7857,6 @@ void TextEditorWidget::insertFromMimeData(const QMimeData *source) if (d->m_codeAssistant.hasContext()) d->m_codeAssistant.destroyContext(); - if (d->m_snippetOverlay->isVisible() && (text.contains('\n') || text.contains('\t'))) d->m_snippetOverlay->accept();