commit 9fa81fc
Devine Lu Linvega
·
2026-01-08 17:18:00 +0000 UTC
parent b9fea37
Fixed crashing bug when window does not exist
1 files changed,
+5,
-4
+5,
-4
1@@ -1291,14 +1291,14 @@ emu_run(void)
2 continue;
3 while(XPending(display))
4 emu_event();
5- if(poll(&fds[1], 1, 0)) {
6- (void)read(fds[1].fd, expirations, 8);
7+ if(fds[1].revents & POLLIN) {
8+ read(fds[1].fd, expirations, 8);
9 screen_update();
10 }
11 has_input = fds[2].revents & POLLIN;
12 has_eof = fds[2].revents & POLLHUP;
13 if(has_input || has_eof) {
14- int i = 1, n = read(fds[2].fd, coninp, CONINBUFSIZE - 1);
15+ int i, n = read(fds[2].fd, coninp, CONINBUFSIZE - 1);
16 for(i = 0, coninp[n] = 0; i < n; i++)
17 console_input(coninp[i], CONSOLE_STD), has_sent = 1;
18 if(n == 0 && has_sent)
19@@ -1307,7 +1307,8 @@ emu_run(void)
20 }
21 if(ximage)
22 XDestroyImage(ximage);
23- XDestroyWindow(display, window);
24+ if(window)
25+ XDestroyWindow(display, window);
26 XCloseDisplay(display);
27 console_close();
28 }