From 72e53e4b87c8b0dc267cac596934e38d3068473d Mon Sep 17 00:00:00 2001
From: Ethan Lee <[EMAIL REDACTED]>
Date: Sun, 28 Nov 2021 19:25:22 -0500
Subject: [PATCH] wayland: Clear driverdata before calling ResetDisplayModes
---
src/video/wayland/SDL_waylandvideo.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c
index f9109f1d9f..6d6d951d4e 100644
--- a/src/video/wayland/SDL_waylandvideo.c
+++ b/src/video/wayland/SDL_waylandvideo.c
@@ -302,8 +302,17 @@ display_handle_geometry(void *data,
{
SDL_WaylandOutputData *driverdata = data;
+ SDL_VideoDisplay *display;
+ int i;
if (driverdata->done) {
+ /* Clear the wl_output ref so Reset doesn't free it */
+ display = SDL_GetDisplay(driverdata->index);
+ for (i = 0; i < display->num_display_modes; i += 1) {
+ display->display_modes[i].driverdata = NULL;
+ }
+
+ /* Okay, now it's safe to reset */
SDL_ResetDisplayModes(driverdata->index);
/* The display has officially started over. */