diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2023-04-18 09:54:27 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2023-04-20 14:29:31 +0000 |
commit | d1d893f0984ca806e576b52ff46252d69fc3cc83 (patch) | |
tree | 902cfc47a7b85a9fc246bde9199449c2007ba8ef /src/plugins/texteditor | |
parent | 0e3089314b1fbafb2a5bf1938b1eb991faf0febe (diff) | |
download | qt-creator-d1d893f0984ca806e576b52ff46252d69fc3cc83.tar.gz |
Fix dangling references, found by GCC 13
Lifetime extension via const-ref only applies to functions that return
by value. For those that already return by reference (such as
QList::constLast()), no extension happens and we end up with a dangling
reference.
cmakebuildconfiguration.cpp:1473:25: warning: possibly dangling reference to a temporary [-Wdangling-reference]
cmakebuildconfiguration.cpp:1473:61: note: the temporary was destroyed at the end of the full expression ‘ProjectExplorer::BuildStepList::steps() const().QList<ProjectExplorer::BuildStep*>::constLast()’
Change-Id: I3b169860d8bd41e9be6bfffd1757167b7348be9b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Diffstat (limited to 'src/plugins/texteditor')
-rw-r--r-- | src/plugins/texteditor/texteditor.cpp | 4 | ||||
-rw-r--r-- | src/plugins/texteditor/textmark.cpp | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 3b8f5505d6..bed196a76c 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -2905,9 +2905,9 @@ void TextEditorWidget::insertCodeSnippet(const QTextCursor &cursor_arg, d->m_document->autoIndent(cursor); cursor.endEditBlock(); - const QColor &occurrencesColor + const QColor occurrencesColor = textDocument()->fontSettings().toTextCharFormat(C_OCCURRENCES).background().color(); - const QColor &renameColor + const QColor renameColor = textDocument()->fontSettings().toTextCharFormat(C_OCCURRENCES_RENAME).background().color(); for (const CursorPart &part : cursorParts) { diff --git a/src/plugins/texteditor/textmark.cpp b/src/plugins/texteditor/textmark.cpp index 4eadb4b4c6..ddf354ea92 100644 --- a/src/plugins/texteditor/textmark.cpp +++ b/src/plugins/texteditor/textmark.cpp @@ -132,7 +132,7 @@ void TextMark::paintAnnotation(QPainter &painter, const QColor &markColor = annotationColor(); const FontSettings &fontSettings = m_baseTextDocument->fontSettings(); - const AnnotationColors &colors = AnnotationColors::getAnnotationColors( + const AnnotationColors colors = AnnotationColors::getAnnotationColors( markColor.isValid() ? markColor : painter.pen().color(), fontSettings.toTextCharFormat(C_TEXT).background().color()); |