aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2022-12-07 16:55:38 +0100
committerJarek Kobus <jaroslaw.kobus@qt.io>2022-12-08 13:52:12 +0000
commitb0e694349143bb88047755a94e808a33725f92ee (patch)
tree2c32649181666c609829d20865ae3238664fdd03
parent6bef53a81882b61308e987569f3254e8a4aa4775 (diff)
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: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
-rw-r--r--src/plugins/texteditor/texteditor.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp
index 3594493013..303c588466 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();