mirror of https://github.com/libsdl-org/SDL.git
wayland: Fix memory leaks
Fix some memory leaks reported by Valgrind due to not destroying objects.
This commit is contained in:
parent
b221b59995
commit
fb68e84646
|
|
@ -311,12 +311,25 @@ static SDL_bool keyboard_repeat_key_is_set(SDL_WaylandKeyboardRepeat *repeat_inf
|
|||
return repeat_info->is_initialized && repeat_info->is_key_down && key == repeat_info->key;
|
||||
}
|
||||
|
||||
static void sync_done_handler(void *data, struct wl_callback *callback, uint32_t callback_data)
|
||||
{
|
||||
/* Nothing to do, just destroy the callback */
|
||||
wl_callback_destroy(callback);
|
||||
}
|
||||
|
||||
static struct wl_callback_listener sync_listener = {
|
||||
sync_done_handler
|
||||
};
|
||||
|
||||
void Wayland_SendWakeupEvent(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
SDL_VideoData *d = _this->driverdata;
|
||||
|
||||
/* TODO: Maybe use a pipe to avoid the compositor roundtrip? */
|
||||
wl_display_sync(d->display);
|
||||
/* Queue a sync event to unblock the event queue fd if it's empty and being waited on.
|
||||
* TODO: Maybe use a pipe to avoid the compositor roundtrip?
|
||||
*/
|
||||
struct wl_callback *cb = wl_display_sync(d->display);
|
||||
wl_callback_add_listener(cb, &sync_listener, NULL);
|
||||
WAYLAND_wl_display_flush(d->display);
|
||||
}
|
||||
|
||||
|
|
@ -2705,6 +2718,9 @@ void Wayland_display_destroy_input(SDL_VideoData *d)
|
|||
if (input->primary_selection_device->selection_source != NULL) {
|
||||
Wayland_primary_selection_source_destroy(input->primary_selection_device->selection_source);
|
||||
}
|
||||
if (input->primary_selection_device->primary_selection_device != NULL) {
|
||||
zwp_primary_selection_device_v1_destroy(input->primary_selection_device->primary_selection_device);
|
||||
}
|
||||
SDL_free(input->primary_selection_device);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -672,6 +672,10 @@ static void Wayland_free_display(SDL_VideoDisplay *display)
|
|||
SDL_DisplayData *display_data = display->driverdata;
|
||||
int i;
|
||||
|
||||
if (display_data->xdg_output) {
|
||||
zxdg_output_v1_destroy(display_data->xdg_output);
|
||||
}
|
||||
|
||||
if (wl_output_get_version(display_data->output) >= WL_OUTPUT_RELEASE_SINCE_VERSION) {
|
||||
wl_output_release(display_data->output);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue