mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-08 13:38:05 +02:00
compositor: add screenshooter destructor
Nothing was freeing the allocation from screenshooter_create(). Add enough boilerplate, that we can free it. Fixes a Valgrind leak. Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
This commit is contained in:
parent
c069dd548f
commit
35ce06d4ae
3 changed files with 28 additions and 7 deletions
|
|
@ -2006,7 +2006,7 @@ wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display)
|
|||
ec->fade.animation.frame = fade_frame;
|
||||
wl_list_init(&ec->fade.animation.link);
|
||||
|
||||
screenshooter_create(ec);
|
||||
ec->screenshooter = screenshooter_create(ec);
|
||||
|
||||
wlsc_data_device_manager_init(ec);
|
||||
|
||||
|
|
@ -2036,6 +2036,9 @@ wlsc_compositor_shutdown(struct wlsc_compositor *ec)
|
|||
|
||||
wl_event_source_remove(ec->idle_source);
|
||||
|
||||
if (ec->screenshooter)
|
||||
screenshooter_destroy(ec->screenshooter);
|
||||
|
||||
/* Destroy all outputs associated with this compositor */
|
||||
wl_list_for_each_safe(output, next, &ec->output_list, link)
|
||||
output->destroy(output);
|
||||
|
|
|
|||
|
|
@ -169,6 +169,8 @@ enum {
|
|||
WLSC_COMPOSITOR_SLEEPING /* no rendering, no frame events */
|
||||
};
|
||||
|
||||
struct screenshooter;
|
||||
|
||||
struct wlsc_compositor {
|
||||
struct wl_shm *shm;
|
||||
struct wlsc_xserver *wxs;
|
||||
|
|
@ -225,6 +227,8 @@ struct wlsc_compositor {
|
|||
int (*authenticate)(struct wlsc_compositor *c, uint32_t id);
|
||||
EGLImageKHR (*create_cursor_image)(struct wlsc_compositor *c,
|
||||
int32_t *width, int32_t *height);
|
||||
|
||||
struct screenshooter *screenshooter;
|
||||
};
|
||||
|
||||
#define MODIFIER_CTRL (1 << 8)
|
||||
|
|
@ -426,9 +430,12 @@ tty_create(struct wlsc_compositor *compositor, tty_vt_func_t vt_func,
|
|||
void
|
||||
tty_destroy(struct tty *tty);
|
||||
|
||||
void
|
||||
struct screenshooter *
|
||||
screenshooter_create(struct wlsc_compositor *ec);
|
||||
|
||||
void
|
||||
screenshooter_destroy(struct screenshooter *shooter);
|
||||
|
||||
uint32_t *
|
||||
wlsc_load_image(const char *filename,
|
||||
int32_t *width_arg, int32_t *height_arg, uint32_t *stride_arg);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
struct screenshooter {
|
||||
struct wl_object base;
|
||||
struct wlsc_compositor *ec;
|
||||
struct wl_global *global;
|
||||
};
|
||||
|
||||
static void
|
||||
|
|
@ -64,20 +65,30 @@ bind_shooter(struct wl_client *client,
|
|||
&screenshooter_implementation, id, data);
|
||||
}
|
||||
|
||||
void
|
||||
struct screenshooter *
|
||||
screenshooter_create(struct wlsc_compositor *ec)
|
||||
{
|
||||
struct screenshooter *shooter;
|
||||
|
||||
shooter = malloc(sizeof *shooter);
|
||||
if (shooter == NULL)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
shooter->base.interface = &screenshooter_interface;
|
||||
shooter->base.implementation =
|
||||
(void(**)(void)) &screenshooter_implementation;
|
||||
shooter->ec = ec;
|
||||
|
||||
wl_display_add_global(ec->wl_display,
|
||||
&screenshooter_interface, shooter, bind_shooter);
|
||||
};
|
||||
shooter->global = wl_display_add_global(ec->wl_display,
|
||||
&screenshooter_interface,
|
||||
shooter, bind_shooter);
|
||||
|
||||
return shooter;
|
||||
}
|
||||
|
||||
void
|
||||
screenshooter_destroy(struct screenshooter *shooter)
|
||||
{
|
||||
wl_display_remove_global(shooter->ec->wl_display, shooter->global);
|
||||
free(shooter);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue