Clean up some resources

pull/1/head
Andri Yngvason 2019-12-27 14:41:54 +00:00
parent 9adac0e683
commit 09772ddf5b
3 changed files with 21 additions and 3 deletions

View File

@ -31,3 +31,4 @@ struct screencopy {
}; };
void screencopy_init(struct screencopy* self); void screencopy_init(struct screencopy* self);
void screencopy_destroy(struct screencopy* self);

View File

@ -26,6 +26,7 @@
#include <neatvnc.h> #include <neatvnc.h>
#include <uv.h> #include <uv.h>
#include <libdrm/drm_fourcc.h> #include <libdrm/drm_fourcc.h>
#include <wayland-client-protocol.h>
#include <wayland-client.h> #include <wayland-client.h>
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
#include <GLES2/gl2ext.h> #include <GLES2/gl2ext.h>
@ -188,13 +189,22 @@ static void registry_remove(void* data, struct wl_registry* registry,
void wayvnc_destroy(struct wayvnc* self) void wayvnc_destroy(struct wayvnc* self)
{ {
output_list_destroy(&self->outputs); output_list_destroy(&self->outputs);
wl_seat_destroy(self->seat);
wl_shm_destroy(self->screencopy_backend.wl_shm);
zwp_virtual_keyboard_v1_destroy(self->keyboard_backend.virtual_keyboard); zwp_virtual_keyboard_v1_destroy(self->keyboard_backend.virtual_keyboard);
zwp_virtual_keyboard_manager_v1_destroy(self->keyboard_manager); zwp_virtual_keyboard_manager_v1_destroy(self->keyboard_manager);
keyboard_destroy(&self->keyboard_backend);
zwlr_virtual_pointer_manager_v1_destroy(self->pointer_backend.manager); zwlr_virtual_pointer_manager_v1_destroy(self->pointer_backend.manager);
if (self->dmabuf_backend.manager) { pointer_destroy(&self->pointer_backend);
pointer_destroy(&self->pointer_backend);
zwlr_screencopy_manager_v1_destroy(self->screencopy_backend.manager);
if (self->dmabuf_backend.manager)
zwlr_export_dmabuf_manager_v1_destroy(self->dmabuf_backend.manager); zwlr_export_dmabuf_manager_v1_destroy(self->dmabuf_backend.manager);
}
wl_display_disconnect(self->display); wl_display_disconnect(self->display);
} }
@ -619,6 +629,7 @@ int main(int argc, char* argv[])
nvnc_close(self.nvnc); nvnc_close(self.nvnc);
renderer_destroy(&self.renderer); renderer_destroy(&self.renderer);
screencopy_destroy(&self.screencopy_backend);
wayvnc_destroy(&self); wayvnc_destroy(&self);
return 0; return 0;

View File

@ -19,6 +19,7 @@
#include <assert.h> #include <assert.h>
#include <stdbool.h> #include <stdbool.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <wayland-client-protocol.h>
#include <wayland-client.h> #include <wayland-client.h>
#include <libdrm/drm_fourcc.h> #include <libdrm/drm_fourcc.h>
@ -189,3 +190,8 @@ void screencopy_init(struct screencopy* self)
self->frame_capture.backend.start = screencopy_start; self->frame_capture.backend.start = screencopy_start;
self->frame_capture.backend.stop = screencopy_stop; self->frame_capture.backend.stop = screencopy_stop;
} }
void screencopy_destroy(struct screencopy* self)
{
wl_buffer_destroy(self->buffer);
}