From 5fff1e414a060c0619a97ad8d3f5665e3f5a4878 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Fri, 9 Jan 2026 16:16:48 +0100 Subject: Use Q_ASSERT instead of Q_CHECK_PTR for plain checks of pointer value Q_CHECK_PTR (other than the name suggests) is intended only to check the success of memory allocations. Using it for any pointers instead can be misleading due to the "Out of memory" log printed in case of hits. --- src/kitemviews/accessibility/kitemlistcontaineraccessible.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/kitemviews/accessibility/kitemlistcontaineraccessible.cpp') diff --git a/src/kitemviews/accessibility/kitemlistcontaineraccessible.cpp b/src/kitemviews/accessibility/kitemlistcontaineraccessible.cpp index 6abf45025..6facae06c 100644 --- a/src/kitemviews/accessibility/kitemlistcontaineraccessible.cpp +++ b/src/kitemviews/accessibility/kitemlistcontaineraccessible.cpp @@ -47,7 +47,7 @@ int KItemListContainerAccessible::indexOfChild(const QAccessibleInterface *child QAccessibleInterface *KItemListContainerAccessible::child(int index) const { if (index == 0) { - Q_CHECK_PTR(static_cast(QAccessible::queryAccessibleInterface(container()->controller()->view()))); + Q_ASSERT(static_cast(QAccessible::queryAccessibleInterface(container()->controller()->view()))); return QAccessible::queryAccessibleInterface(container()->controller()->view()); } qWarning("Calling KItemListContainerAccessible::child(index) with index != 0 is always pointless."); @@ -70,7 +70,7 @@ QAccessible::State KItemListContainerAccessible::state() const void KItemListContainerAccessible::doAction(const QString &actionName) { auto view = static_cast(child(0)); - Q_CHECK_PTR(view); // A container should always have a view. Otherwise it has no reason to exist. + Q_ASSERT(view); // A container should always have a view. Otherwise it has no reason to exist. if (actionName == setFocusAction() && view) { view->doAction(actionName); return; @@ -80,6 +80,6 @@ void KItemListContainerAccessible::doAction(const QString &actionName) const KItemListContainer *KItemListContainerAccessible::container() const { - Q_CHECK_PTR(qobject_cast(object())); + Q_ASSERT(qobject_cast(object())); return static_cast(object()); } -- cgit v1.3