From 979c8cf1b75e3e0e0dcf7c718c3fed6fdfdd7ea3 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 28 Oct 2020 09:59:31 +0100 Subject: [PATCH] Always return initialized data from QBindable::value clang warned about result being uninitialized if iface is nullptr. Return a properly initialized result in that case as well. This might break RVO, but the alternative is to always initialize result, even if we are going to call the getter anyway, which I assume would be more expensive. Change-Id: I5d6d243b3094b79bf021725d017be5c72b1089bb Reviewed-by: Lars Knoll --- src/corelib/kernel/qproperty.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/corelib/kernel/qproperty.h b/src/corelib/kernel/qproperty.h index 9ee7a1ef3f..8b400e7285 100644 --- a/src/corelib/kernel/qproperty.h +++ b/src/corelib/kernel/qproperty.h @@ -651,10 +651,12 @@ public: T value() const { - T result; - if (iface) + if (iface) { + T result; iface->getter(data, &result); - return result; + return result; + } + return T{}; } void setValue(const T &value)