From 60b134d0d77a1eadf594eeab8d0cc7e85d7ce905 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 19 Mar 2021 15:56:47 +0100 Subject: 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. Pick-to: 6.1 Change-Id: I70f4e27eaa5e26538884ead19ae12da7bacbd76b Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquicktumbler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/quicktemplates2') 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. -- cgit v1.2.3