From 1ffe49dd199a6c502ed8c145e102de747284ba56 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 17 Jun 2022 17:34:55 +0200 Subject: [PATCH] QWindowPrivate::setMinOrMaxSize: port to function_ref MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "callbacks" passed to setMinOrMaxSize are not stored and outlive the callee. Therefore, don't use std::function to pass them (by value (!)); instead employ the recently-added function_ref. Change-Id: I37eea020920a76c063265e667c99a6040394d645 Reviewed-by: Tor Arne Vestbø Reviewed-by: Marc Mutz --- src/gui/kernel/qwindow.cpp | 5 ++--- src/gui/kernel/qwindow_p.h | 5 +++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index e06951071f..afbde03619 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -568,12 +568,11 @@ QRectF QWindowPrivate::closestAcceptableGeometry(const QRectF &rect) const } void QWindowPrivate::setMinOrMaxSize(QSize *oldSizeMember, const QSize &size, - std::function funcWidthChanged, - std::function funcHeightChanged) + qxp::function_ref funcWidthChanged, + qxp::function_ref funcHeightChanged) { Q_Q(QWindow); Q_ASSERT(oldSizeMember); - Q_ASSERT(funcWidthChanged && funcHeightChanged); const QSize adjustedSize = size.expandedTo(QSize(0, 0)).boundedTo(QSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX)); if (*oldSizeMember == adjustedSize) diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index 3212a1d6fa..cf6a6934eb 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -22,6 +22,7 @@ #include #include +#include #include QT_BEGIN_NAMESPACE @@ -74,8 +75,8 @@ public: virtual QRectF closestAcceptableGeometry(const QRectF &rect) const; void setMinOrMaxSize(QSize *oldSizeMember, const QSize &size, - std::function funcWidthChanged, - std::function funcHeightChanged); + qxp::function_ref funcWidthChanged, + qxp::function_ref funcHeightChanged); virtual void processSafeAreaMarginsChanged() {}