From 27c55ac5d3b925d9d158ab919bd98b71e8953ad1 Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Mon, 16 Feb 2015 07:28:11 +0000
Subject: [PATCH] Add the cheery_reaper() function which waits 500ms then calls
 exit(0).  This ensures the program quits when the user presses the exit
 button and the program doesn't handle CIO_KEY_QUIT.

This still isn't the best way to do things.
---
 src/conio/sdl_con.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/conio/sdl_con.c b/src/conio/sdl_con.c
index 2c20270747..db744294f6 100644
--- a/src/conio/sdl_con.c
+++ b/src/conio/sdl_con.c
@@ -1465,6 +1465,17 @@ int win_to_text_ypos(int winpos)
 }
 
 /* Event Thread */
+/*
+ * This function waits 500ms then calls exit().
+ * It's used to handle the "close" button if the program doesn't deal
+ * with CIO_KEY_QUIT.
+ */
+void cheery_reaper(void)
+{
+	SLEEP(500);
+	exit(0);
+}
+
 int sdl_video_event_thread(void *data)
 {
 	SDL_Event	ev;
@@ -1537,6 +1548,7 @@ int sdl_video_event_thread(void *data)
 						break;
 					case SDL_QUIT:
 						sdl_add_key(CIO_KEY_QUIT);
+						cheery_reaper();
 						break;
 					case SDL_VIDEORESIZE:
 						if(ev.resize.w > 0 && ev.resize.h > 0) {
-- 
GitLab