From 435f899f063297ec010f1add594fbc43805c7642 Mon Sep 17 00:00:00 2001 From: Lu YaNing Date: Tue, 19 Mar 2024 09:53:53 +0800 Subject: Use static_cast rather than dynamic_cast To avoid RTTI. When I tried to implement the reconnect function in Plasma5, I found that the application would have a dynamic_cast crash problem. Referring to other usage logic and suggestions in Qt, it is recommended to avoid using dynamic_cast. Change-Id: I4fd41846c3215f60aafc7e38d1542d52ec6759b8 Reviewed-by: David Redondo --- src/client/qwaylanddisplay.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp index 97b04b1dc..265f0bb3f 100644 --- a/src/client/qwaylanddisplay.cpp +++ b/src/client/qwaylanddisplay.cpp @@ -454,13 +454,13 @@ void QWaylandDisplay::reconnect() const auto windows = QGuiApplication::allWindows(); for (auto window : windows) { - if (auto waylandWindow = dynamic_cast(window->handle())) + if (auto waylandWindow = static_cast(window->handle())) waylandWindow->closeChildPopups(); } // Remove windows that do not need to be recreated and now closed popups QList recreateWindows; for (auto window : std::as_const(windows)) { - auto waylandWindow = dynamic_cast((window)->handle()); + auto waylandWindow = static_cast(window->handle()); if (waylandWindow && waylandWindow->wlSurface()) { waylandWindow->reset(); recreateWindows.push_back(waylandWindow); -- cgit v1.2.3