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>
This commit is contained in:
parent
1d6cecbb4a
commit
e89e8bf73f
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user