From e86da1f231c5adc637582f1a518fdade74579776 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= jaakko.keranen@iki.fi
Date: Wed, 10 Feb 2021 11:10:41 +0200
Subject: [PATCH 1/1] App: Events posted early may cause a crash
Attempting to ask SDL about a non-existent window's ID.
src/app.c | 6 +++---
src/ui/window.c | 4 ++++
src/ui/window.h | 1 +
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/app.c b/src/app.c
index d4b2ab54..4eeae94e 100644
--- a/src/app.c
+++ b/src/app.c
@@ -689,7 +689,7 @@ static int resizeWatcher_(void *user, SDL_Event *event) {
SDL_Event u = { .type = SDL_USEREVENT };
u.user.code = command_UserEventCode;
u.user.data1 = strdup("theme.changed");
u.user.windowID = SDL_GetWindowID(d->window->win);
u.user.windowID = id_Window(d->window);
dispatchEvent_Widget(d->window->root, &u);
}
#endif
@@ -782,7 +782,7 @@ void postRefresh_App(void) {
SDL_Event ev;
ev.user.type = SDL_USEREVENT;
ev.user.code = refresh_UserEventCode;
ev.user.windowID = get_Window() ? SDL_GetWindowID(get_Window()->win) : 0;
ev.user.windowID = id_Window(get_Window());
ev.user.data1 = NULL;
ev.user.data2 = NULL;
SDL_PushEvent(&ev);
@@ -807,7 +807,7 @@ void postCommand_App(const char *command) {
}
ev.user.type = SDL_USEREVENT;
ev.user.code = command_UserEventCode;
ev.user.data1 = strdup(command);
ev.user.data2 = NULL;
SDL_PushEvent(&ev);
diff --git a/src/ui/window.c b/src/ui/window.c
index 7c16cf09..5101ed9b 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -1042,6 +1042,10 @@ void setCursor_Window(iWindow *d, int cursor) {
d->pendingCursor = d->cursors[cursor];
}
+uint32_t id_Window(const iWindow *d) {
+}
iInt2 rootSize_Window(const iWindow *d) {
return d->root->rect.size;
}
diff --git a/src/ui/window.h b/src/ui/window.h
index bdd4d008..8be8b88d 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -60,6 +60,7 @@ void setUiScale_Window (iWindow *, float uiScale);
void setFreezeDraw_Window (iWindow *, iBool freezeDraw);
void setCursor_Window (iWindow *, int cursor);
+uint32_t id_Window (const iWindow *);
iInt2 rootSize_Window (const iWindow *);
float uiScale_Window (const iWindow *);
iInt2 coord_Window (const iWindow *, int x, int y);
--
2.25.1
text/plain
This content has been proxied by September (ba2dc).