summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-02-25 14:19:34 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-03-04 05:51:13 +0000
commitdcbaf539eafd6e8190cab29744ab6483993f4fd0 (patch)
tree703c45277ffd4a452a98567855e0c0e1bf5b4dd2 /src
parent8ba766c086d6ea980b5208b18af3b63a6fed7015 (diff)
QLabel: simplify createStandardContextMenu
If control is nullptr in the beginning, then it will be nullptr later as well, and the function won't do anything. And if the effectiveTextFormat is Qt::PlainText, then the linkToCopy will be empty, and the function won't do anything, either. So we can just handle these cases right away, making the code simplier. Fixes static analyzer warning 43de3f3125108b4353afd94e94f59926. Change-Id: I5b8eb94a1e40c2725de6a168298d8f3bcde748eb Reviewed-by: David Skoland <david.skoland@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> (cherry picked from commit e718818745e6db8df09ea55c4071e116f00851c9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/widgets/qlabel.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp
index 2d7b7f79b1..189a7488d3 100644
--- a/src/widgets/widgets/qlabel.cpp
+++ b/src/widgets/widgets/qlabel.cpp
@@ -1694,14 +1694,13 @@ QPoint QLabelPrivate::layoutPoint(const QPoint& p) const
#ifndef QT_NO_CONTEXTMENU
QMenu *QLabelPrivate::createStandardContextMenu(const QPoint &pos)
{
- QString linkToCopy;
- QPoint p;
- if (control && effectiveTextFormat != Qt::PlainText) {
- p = layoutPoint(pos);
- linkToCopy = control->document()->documentLayout()->anchorAt(p);
- }
+ if (!control || effectiveTextFormat == Qt::PlainText)
+ return nullptr;
+
+ const QPoint p = layoutPoint(pos);
+ QString linkToCopy = control->document()->documentLayout()->anchorAt(p);
- if (linkToCopy.isEmpty() && !control)
+ if (linkToCopy.isEmpty())
return nullptr;
return control->createStandardContextMenu(p, q_func());