fix: fix cast in ElectronDesktopWindowTreeHostLinux (#42185)

Fix cast in ElectronDesktopWindowTreeHostLinux

The frame view of the widget is an `ClientFrameViewLinux` instance only
when both `frame` and `client_frame` booleans are set to `true`.
Otherwise it is an instance of a different class and thus casting to
`ClientFrameViewLinux` is incorrect and leads to crashes.

Fix: #41839

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Fedor Indutny <indutny@signal.org>
This commit is contained in:
trop[bot] 2024-05-14 16:14:45 -07:00 committed by GitHub
parent c0e5ef40cc
commit 60f48e1753
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -71,9 +71,15 @@ void ElectronDesktopWindowTreeHostLinux::OnWindowStateChanged(
void ElectronDesktopWindowTreeHostLinux::OnWindowTiledStateChanged( void ElectronDesktopWindowTreeHostLinux::OnWindowTiledStateChanged(
ui::WindowTiledEdges new_tiled_edges) { ui::WindowTiledEdges new_tiled_edges) {
static_cast<ClientFrameViewLinux*>( // CreateNonClientFrameView creates `ClientFrameViewLinux` only when both
native_window_view_->widget()->non_client_view()->frame_view()) // frame and client_frame booleans are set, otherwise it is a different type
->set_tiled_edges(new_tiled_edges); // of view.
if (native_window_view_->has_frame() &&
native_window_view_->has_client_frame()) {
static_cast<ClientFrameViewLinux*>(
native_window_view_->widget()->non_client_view()->frame_view())
->set_tiled_edges(new_tiled_edges);
}
UpdateFrameHints(); UpdateFrameHints();
} }