diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-03-19 15:56:47 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-03-25 11:13:20 +0000 |
commit | e2f4210444daba67e8bb58d57660d00f035a98e7 (patch) | |
tree | 6640e1a94b848b1659af1b6b68e0fc95c8ab96cd | |
parent | 6495c0da733cc16f07d0aa6db03ddadd646d3ee9 (diff) |
Consistently check for nullptr
Since delegateItem might be nullptr after the qobject_cast, it might
still be nullptr even if d->tumbler is set. Don't dereference it without
checking first.
Fixes static analzyer warning 97aff83b6782555664df70d92f65e7dd.
Change-Id: I70f4e27eaa5e26538884ead19ae12da7bacbd76b
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
(cherry picked from commit 60b134d0d77a1eadf594eeab8d0cc7e85d7ce905)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/quicktemplates2/qquicktumbler.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/quicktemplates2/qquicktumbler.cpp b/src/quicktemplates2/qquicktumbler.cpp index 5f17cd29..4f7d3487 100644 --- a/src/quicktemplates2/qquicktumbler.cpp +++ b/src/quicktemplates2/qquicktumbler.cpp @@ -995,7 +995,7 @@ QQuickTumblerAttached::QQuickTumblerAttached(QObject *parent) QQuickTumblerPrivate *tumblerPrivate = QQuickTumblerPrivate::get(d->tumbler); tumblerPrivate->setupViewData(tumblerPrivate->contentItem); - if (delegateItem->parentItem() == tumblerPrivate->viewContentItem) { + if (delegateItem && delegateItem->parentItem() == tumblerPrivate->viewContentItem) { // This item belongs to the "new" view, meaning that the tumbler's contentItem // was probably assigned declaratively. If they're not equal, calling // calculateDisplacement() would use the old contentItem data, which is bad. |