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:
@@ -2006,7 +2006,7 @@ wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display)
|
|||||||
ec->fade.animation.frame = fade_frame;
|
ec->fade.animation.frame = fade_frame;
|
||||||
wl_list_init(&ec->fade.animation.link);
|
wl_list_init(&ec->fade.animation.link);
|
||||||
|
|
||||||
screenshooter_create(ec);
|
ec->screenshooter = screenshooter_create(ec);
|
||||||
|
|
||||||
wlsc_data_device_manager_init(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);
|
wl_event_source_remove(ec->idle_source);
|
||||||
|
|
||||||
|
if (ec->screenshooter)
|
||||||
|
screenshooter_destroy(ec->screenshooter);
|
||||||
|
|
||||||
/* Destroy all outputs associated with this compositor */
|
/* Destroy all outputs associated with this compositor */
|
||||||
wl_list_for_each_safe(output, next, &ec->output_list, link)
|
wl_list_for_each_safe(output, next, &ec->output_list, link)
|
||||||
output->destroy(output);
|
output->destroy(output);
|
||||||
|
|||||||
@@ -169,6 +169,8 @@ enum {
|
|||||||
WLSC_COMPOSITOR_SLEEPING /* no rendering, no frame events */
|
WLSC_COMPOSITOR_SLEEPING /* no rendering, no frame events */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct screenshooter;
|
||||||
|
|
||||||
struct wlsc_compositor {
|
struct wlsc_compositor {
|
||||||
struct wl_shm *shm;
|
struct wl_shm *shm;
|
||||||
struct wlsc_xserver *wxs;
|
struct wlsc_xserver *wxs;
|
||||||
@@ -225,6 +227,8 @@ struct wlsc_compositor {
|
|||||||
int (*authenticate)(struct wlsc_compositor *c, uint32_t id);
|
int (*authenticate)(struct wlsc_compositor *c, uint32_t id);
|
||||||
EGLImageKHR (*create_cursor_image)(struct wlsc_compositor *c,
|
EGLImageKHR (*create_cursor_image)(struct wlsc_compositor *c,
|
||||||
int32_t *width, int32_t *height);
|
int32_t *width, int32_t *height);
|
||||||
|
|
||||||
|
struct screenshooter *screenshooter;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MODIFIER_CTRL (1 << 8)
|
#define MODIFIER_CTRL (1 << 8)
|
||||||
@@ -426,9 +430,12 @@ tty_create(struct wlsc_compositor *compositor, tty_vt_func_t vt_func,
|
|||||||
void
|
void
|
||||||
tty_destroy(struct tty *tty);
|
tty_destroy(struct tty *tty);
|
||||||
|
|
||||||
void
|
struct screenshooter *
|
||||||
screenshooter_create(struct wlsc_compositor *ec);
|
screenshooter_create(struct wlsc_compositor *ec);
|
||||||
|
|
||||||
|
void
|
||||||
|
screenshooter_destroy(struct screenshooter *shooter);
|
||||||
|
|
||||||
uint32_t *
|
uint32_t *
|
||||||
wlsc_load_image(const char *filename,
|
wlsc_load_image(const char *filename,
|
||||||
int32_t *width_arg, int32_t *height_arg, uint32_t *stride_arg);
|
int32_t *width_arg, int32_t *height_arg, uint32_t *stride_arg);
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
struct screenshooter {
|
struct screenshooter {
|
||||||
struct wl_object base;
|
struct wl_object base;
|
||||||
struct wlsc_compositor *ec;
|
struct wlsc_compositor *ec;
|
||||||
|
struct wl_global *global;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -64,20 +65,30 @@ bind_shooter(struct wl_client *client,
|
|||||||
&screenshooter_implementation, id, data);
|
&screenshooter_implementation, id, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
struct screenshooter *
|
||||||
screenshooter_create(struct wlsc_compositor *ec)
|
screenshooter_create(struct wlsc_compositor *ec)
|
||||||
{
|
{
|
||||||
struct screenshooter *shooter;
|
struct screenshooter *shooter;
|
||||||
|
|
||||||
shooter = malloc(sizeof *shooter);
|
shooter = malloc(sizeof *shooter);
|
||||||
if (shooter == NULL)
|
if (shooter == NULL)
|
||||||
return;
|
return NULL;
|
||||||
|
|
||||||
shooter->base.interface = &screenshooter_interface;
|
shooter->base.interface = &screenshooter_interface;
|
||||||
shooter->base.implementation =
|
shooter->base.implementation =
|
||||||
(void(**)(void)) &screenshooter_implementation;
|
(void(**)(void)) &screenshooter_implementation;
|
||||||
shooter->ec = ec;
|
shooter->ec = ec;
|
||||||
|
|
||||||
wl_display_add_global(ec->wl_display,
|
shooter->global = wl_display_add_global(ec->wl_display,
|
||||||
&screenshooter_interface, shooter, bind_shooter);
|
&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);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user