Fix memory leaks

This commit is contained in:
Versus Void 2017-10-05 20:01:56 +00:00
parent edadbc7c7f
commit c5df6ca900
9 changed files with 23 additions and 6 deletions

View File

@ -34,8 +34,8 @@ static void wlr_drm_backend_destroy(struct wlr_backend *backend) {
wlr_output_destroy(&conn->output); wlr_output_destroy(&conn->output);
} }
wlr_drm_renderer_finish(&drm->renderer);
wlr_drm_resources_free(drm); wlr_drm_resources_free(drm);
wlr_drm_renderer_finish(&drm->renderer);
wlr_session_close_file(drm->session, drm->fd); wlr_session_close_file(drm->session, drm->fd);
wl_event_source_remove(drm->drm_event); wl_event_source_remove(drm->drm_event);
list_free(drm->outputs); list_free(drm->outputs);

View File

@ -169,6 +169,19 @@ void wlr_drm_resources_free(struct wlr_drm_backend *drm) {
drmModeDestroyPropertyBlob(drm->fd, crtc->mode_id); drmModeDestroyPropertyBlob(drm->fd, crtc->mode_id);
} }
} }
for (size_t i = 0; i < drm->num_planes; ++i) {
struct wlr_drm_plane *plane = &drm->planes[i];
if (plane->cursor_bo) {
gbm_bo_destroy(plane->cursor_bo);
}
if (plane->wlr_tex) {
wlr_texture_destroy(plane->wlr_tex);
}
if (plane->wlr_rend) {
wlr_renderer_destroy(plane->wlr_rend);
}
}
free(drm->crtcs); free(drm->crtcs);
free(drm->planes); free(drm->planes);
} }

View File

@ -16,7 +16,6 @@ struct roots_output {
struct roots_desktop *desktop; struct roots_desktop *desktop;
struct wlr_output *wlr_output; struct wlr_output *wlr_output;
struct wl_listener frame; struct wl_listener frame;
struct wl_listener resolution;
struct timespec last_frame; struct timespec last_frame;
struct wl_list link; struct wl_list link;
}; };

View File

@ -76,6 +76,7 @@ struct roots_input {
// TODO: multiseat, multicursor // TODO: multiseat, multicursor
struct wlr_cursor *cursor; struct wlr_cursor *cursor;
struct wlr_xcursor_theme *theme;
struct wlr_xcursor *xcursor; struct wlr_xcursor *xcursor;
struct wlr_seat *wl_seat; struct wlr_seat *wl_seat;

View File

@ -95,6 +95,7 @@ static void init_default_shaders() {
} }
wlr_log(L_DEBUG, "Compiled default shaders"); wlr_log(L_DEBUG, "Compiled default shaders");
shaders.initialized = true;
return; return;
error: error:
wlr_log(L_ERROR, "Failed to set up default shaders!"); wlr_log(L_ERROR, "Failed to set up default shaders!");

View File

@ -79,9 +79,8 @@ struct roots_input *input_create(struct roots_server *server,
input->config = config; input->config = config;
input->server = server; input->server = server;
struct wlr_xcursor_theme *theme; assert(input->theme = wlr_xcursor_theme_load("default", 16));
assert(theme = wlr_xcursor_theme_load("default", 16)); assert(input->xcursor = wlr_xcursor_theme_get_cursor(input->theme, "left_ptr"));
assert(input->xcursor = wlr_xcursor_theme_get_cursor(theme, "left_ptr"));
assert(input->wl_seat = wlr_seat_create(server->wl_display, "seat0")); assert(input->wl_seat = wlr_seat_create(server->wl_display, "seat0"));
wlr_seat_set_capabilities(input->wl_seat, WL_SEAT_CAPABILITY_KEYBOARD wlr_seat_set_capabilities(input->wl_seat, WL_SEAT_CAPABILITY_KEYBOARD

View File

@ -43,5 +43,6 @@ int main(int argc, char **argv) {
setenv("WAYLAND_DISPLAY", socket, true); setenv("WAYLAND_DISPLAY", socket, true);
wl_display_run(server.wl_display); wl_display_run(server.wl_display);
wlr_backend_destroy(server.backend);
return 0; return 0;
} }

View File

@ -147,6 +147,5 @@ void output_remove_notify(struct wl_listener *listener, void *data) {
// sample->compositor); // sample->compositor);
wl_list_remove(&output->link); wl_list_remove(&output->link);
wl_list_remove(&output->frame.link); wl_list_remove(&output->frame.link);
wl_list_remove(&output->resolution.link);
free(output); free(output);
} }

View File

@ -83,6 +83,10 @@ static void wlr_xwayland_surface_destroy(struct wlr_xwayland_surface *surface) {
} }
list_free(surface->state); list_free(surface->state);
free(surface->window_type); free(surface->window_type);
free(surface->protocols);
free(surface->class);
free(surface->instance);
free(surface->title);
free(surface); free(surface);
} }