From e89e8bf73fb2c26672220d68eef05f8eaba3ab18 Mon Sep 17 00:00:00 2001 From: Lu YaNing Date: Tue, 19 Mar 2024 09:53:53 +0800 Subject: [PATCH] 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/plugins/platforms/wayland/qwaylanddisplay.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index 97b04b1dc5d..265f0bb3f19 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/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);