Skip to content

Commit

Permalink
fix: fix cast in ElectronDesktopWindowTreeHostLinux (#42184)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
trop[bot] and indutny-signal committed May 15, 2024
1 parent ebf09b5 commit a0500a5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions shell/browser/ui/electron_desktop_window_tree_host_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,15 @@ void ElectronDesktopWindowTreeHostLinux::OnWindowStateChanged(

void ElectronDesktopWindowTreeHostLinux::OnWindowTiledStateChanged(
ui::WindowTiledEdges new_tiled_edges) {
static_cast<ClientFrameViewLinux*>(
native_window_view_->widget()->non_client_view()->frame_view())
->set_tiled_edges(new_tiled_edges);
// CreateNonClientFrameView creates `ClientFrameViewLinux` only when both
// frame and client_frame booleans are set, otherwise it is a different type
// 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();
}

Expand Down

0 comments on commit a0500a5

Please sign in to comment.