From c760fba40e9f7c9c0883baa07a8561380668700c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 28 Dec 2021 17:39:21 +0100 Subject: [PATCH] QWindow: use std::exchange when ... exchanging values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces a three-liner with a more elegant, idiomatic one-liner. Pick-to: 6.3 Change-Id: I57fbe5d808dffa44f6fceffb97c47f0c84ccd3df Reviewed-by: Volker Hilsheimer Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qwindow.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 589304ccfc0..030628b5db2 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -2002,9 +2002,7 @@ void QWindowPrivate::destroy() // Unset platformWindow before deleting, so that the destructor of the // platform window does not recurse back into the platform window via // this window during destruction (e.g. as a result of platform events). - QPlatformWindow *pw = platformWindow; - platformWindow = nullptr; - delete pw; + delete std::exchange(platformWindow, nullptr); if (QGuiApplicationPrivate::focus_window == q) QGuiApplicationPrivate::focus_window = q->parent();