diff options
author | Lu YaNing <luyaning@uniontech.com> | 2024-03-19 09:53:53 +0800 |
---|---|---|
committer | Lu YaNing <luyaning@uniontech.com> | 2024-03-21 09:06:41 +0800 |
commit | 435f899f063297ec010f1add594fbc43805c7642 (patch) | |
tree | e37408283c434866dd25412712dd05b88d06ad5c /src | |
parent | cc246c5b53b3804c8d115ad0e7c2d76faffbc8e1 (diff) |
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 <qt@david-redondo.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/client/qwaylanddisplay.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
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<QWaylandWindow *>(window->handle())) + if (auto waylandWindow = static_cast<QWaylandWindow *>(window->handle())) waylandWindow->closeChildPopups(); } // Remove windows that do not need to be recreated and now closed popups QList<QWaylandWindow *> recreateWindows; for (auto window : std::as_const(windows)) { - auto waylandWindow = dynamic_cast<QWaylandWindow*>((window)->handle()); + auto waylandWindow = static_cast<QWaylandWindow*>(window->handle()); if (waylandWindow && waylandWindow->wlSurface()) { waylandWindow->reset(); recreateWindows.push_back(waylandWindow); |