Check weston_head_from_resource for NULL return
If the compositor is disabling a weston_output, weston_head_from_resource can return NULL, so the return code must be checked where used. Fixes #638 Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
This commit is contained in:
parent
623646bbfd
commit
617bb9afc9
@ -285,14 +285,15 @@ input_panel_surface_set_toplevel(struct wl_client *client,
|
||||
struct input_panel_surface *input_panel_surface =
|
||||
wl_resource_get_user_data(resource);
|
||||
struct desktop_shell *shell = input_panel_surface->shell;
|
||||
struct weston_head *head;
|
||||
struct weston_head *head = weston_head_from_resource(output_resource);
|
||||
|
||||
if (head) {
|
||||
wl_list_insert(&shell->input_panel.surfaces,
|
||||
&input_panel_surface->link);
|
||||
|
||||
head = weston_head_from_resource(output_resource);
|
||||
input_panel_surface->output = head->output;
|
||||
input_panel_surface->panel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2890,6 +2890,7 @@ desktop_shell_set_background(struct wl_client *client,
|
||||
wl_resource_get_user_data(surface_resource);
|
||||
struct shell_output *sh_output;
|
||||
struct weston_view *view, *next;
|
||||
struct weston_head *head = weston_head_from_resource(output_resource);
|
||||
|
||||
if (surface->committed) {
|
||||
wl_resource_post_error(surface_resource,
|
||||
@ -2898,6 +2899,9 @@ desktop_shell_set_background(struct wl_client *client,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!head)
|
||||
return;
|
||||
|
||||
wl_list_for_each_safe(view, next, &surface->views, surface_link)
|
||||
weston_view_destroy(view);
|
||||
view = weston_view_create(surface);
|
||||
@ -2905,7 +2909,7 @@ desktop_shell_set_background(struct wl_client *client,
|
||||
surface->committed = background_committed;
|
||||
surface->committed_private = shell;
|
||||
weston_surface_set_label_func(surface, background_get_label);
|
||||
surface->output = weston_head_from_resource(output_resource)->output;
|
||||
surface->output = head->output;
|
||||
weston_view_set_output(view, surface->output);
|
||||
|
||||
sh_output = find_shell_output_from_weston_output(shell, surface->output);
|
||||
@ -2995,6 +2999,7 @@ desktop_shell_set_panel(struct wl_client *client,
|
||||
wl_resource_get_user_data(surface_resource);
|
||||
struct weston_view *view, *next;
|
||||
struct shell_output *sh_output;
|
||||
struct weston_head *head = weston_head_from_resource(output_resource);
|
||||
|
||||
if (surface->committed) {
|
||||
wl_resource_post_error(surface_resource,
|
||||
@ -3003,6 +3008,9 @@ desktop_shell_set_panel(struct wl_client *client,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!head)
|
||||
return;
|
||||
|
||||
wl_list_for_each_safe(view, next, &surface->views, surface_link)
|
||||
weston_view_destroy(view);
|
||||
view = weston_view_create(surface);
|
||||
@ -3010,7 +3018,7 @@ desktop_shell_set_panel(struct wl_client *client,
|
||||
surface->committed = panel_committed;
|
||||
surface->committed_private = shell;
|
||||
weston_surface_set_label_func(surface, panel_get_label);
|
||||
surface->output = weston_head_from_resource(output_resource)->output;
|
||||
surface->output = head->output;
|
||||
weston_view_set_output(view, surface->output);
|
||||
|
||||
sh_output = find_shell_output_from_weston_output(shell, surface->output);
|
||||
|
@ -699,7 +699,6 @@ fullscreen_shell_present_surface(struct wl_client *client,
|
||||
{
|
||||
struct fullscreen_shell *shell =
|
||||
wl_resource_get_user_data(resource);
|
||||
struct weston_output *output;
|
||||
struct weston_surface *surface;
|
||||
struct weston_seat *seat;
|
||||
struct fs_output *fsout;
|
||||
@ -720,8 +719,13 @@ fullscreen_shell_present_surface(struct wl_client *client,
|
||||
}
|
||||
|
||||
if (output_res) {
|
||||
output = weston_head_from_resource(output_res)->output;
|
||||
fsout = fs_output_for_output(output);
|
||||
struct weston_head *head =
|
||||
weston_head_from_resource(output_res);
|
||||
|
||||
if (!head)
|
||||
return;
|
||||
|
||||
fsout = fs_output_for_output(head->output);
|
||||
fs_output_set_surface(fsout, surface, method, 0, 0);
|
||||
} else {
|
||||
replace_default_surface(shell, surface, method);
|
||||
@ -759,13 +763,15 @@ fullscreen_shell_present_surface_for_mode(struct wl_client *client,
|
||||
{
|
||||
struct fullscreen_shell *shell =
|
||||
wl_resource_get_user_data(resource);
|
||||
struct weston_output *output;
|
||||
struct weston_surface *surface;
|
||||
struct weston_seat *seat;
|
||||
struct fs_output *fsout;
|
||||
struct weston_head *head = weston_head_from_resource(output_res);
|
||||
|
||||
output = weston_head_from_resource(output_res)->output;
|
||||
fsout = fs_output_for_output(output);
|
||||
if (!head)
|
||||
return;
|
||||
|
||||
fsout = fs_output_for_output(head->output);
|
||||
|
||||
if (surface_res == NULL) {
|
||||
fs_output_set_surface(fsout, NULL, 0, 0, 0);
|
||||
|
@ -878,8 +878,10 @@ input_panel_surface_set_toplevel(struct wl_client *client,
|
||||
|
||||
head = weston_head_from_resource(output_resource);
|
||||
|
||||
if (head) {
|
||||
ipsurf->type = INPUT_PANEL_TOPLEVEL;
|
||||
ipsurf->output = head->output;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -513,8 +513,12 @@ weston_desktop_xdg_toplevel_protocol_set_fullscreen(struct wl_client *wl_client,
|
||||
weston_desktop_surface_get_implementation_data(dsurface);
|
||||
struct weston_output *output = NULL;
|
||||
|
||||
if (output_resource != NULL)
|
||||
output = weston_head_from_resource(output_resource)->output;
|
||||
if (output_resource != NULL) {
|
||||
struct weston_head *head =
|
||||
weston_head_from_resource(output_resource);
|
||||
if (head)
|
||||
output = head->output;
|
||||
}
|
||||
|
||||
weston_desktop_xdg_toplevel_ensure_added(toplevel);
|
||||
weston_desktop_api_fullscreen_requested(toplevel->base.desktop, dsurface,
|
||||
|
@ -562,8 +562,12 @@ weston_desktop_xdg_toplevel_protocol_set_fullscreen(struct wl_client *wl_client,
|
||||
weston_desktop_surface_get_implementation_data(dsurface);
|
||||
struct weston_output *output = NULL;
|
||||
|
||||
if (output_resource != NULL)
|
||||
output = weston_head_from_resource(output_resource)->output;
|
||||
if (output_resource != NULL) {
|
||||
struct weston_head *head =
|
||||
weston_head_from_resource(output_resource);
|
||||
if (head)
|
||||
output = head->output;
|
||||
}
|
||||
|
||||
weston_desktop_xdg_toplevel_ensure_added(toplevel);
|
||||
weston_desktop_api_fullscreen_requested(toplevel->base.desktop, dsurface,
|
||||
|
Loading…
Reference in New Issue
Block a user