Skip to content

Commit ede76aa

Browse files
committed
[qemu1] Route Ctrl-C event to EmulatorQtWindow::closeRequest.
Before this CL, Ctrl-C exit path was slightly different from user pressing the [x] button on UI -- it would directly request qemu to quit, instead of going via the UI exit code path. The different led to subtle ordering problems in how threads were torn down. This CL unifies the two paths, and fixes a bug in process. See b.android.com/199844#c6 for gory details. - While there, removed a no-op call inside ui_done -- this call was always made too late, after the Qt window had already been cleaned up. BUG=b.android.com/199844 Change-Id: Ife263389b957005915d4e1f77f6b948eb5faf904
1 parent dd7cbdf commit ede76aa

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

android/main-common-ui.c

-1
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,5 @@ void ui_done(void)
662662
{
663663
user_config_done();
664664
emulator_window_done(emulator_window_get());
665-
skin_winsys_quit_request();
666665
skin_winsys_destroy();
667666
}

os-posix.c

+11
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
#include "net/net.h"
4040
#include "qemu-options.h"
4141

42+
#ifdef CONFIG_ANDROID
43+
#include "android/skin/winsys.h"
44+
#endif
45+
4246
#ifdef CONFIG_LINUX
4347
#include <sys/prctl.h>
4448
#include <sys/syscall.h>
@@ -64,7 +68,14 @@ void os_setup_early_signal_handling(void)
6468

6569
static void termsig_handler(int signal)
6670
{
71+
#ifdef CONFIG_ANDROID
72+
// In android, request closing the UI, instead of short-circuting down to
73+
// qemu. This will eventually call qemu_system_shutdown_request via a skin
74+
// event.
75+
skin_winsys_quit_request();
76+
#else
6777
qemu_system_shutdown_request();
78+
#endif //!CONFIG_ANDROID
6879
}
6980

7081
#ifndef CONFIG_ANDROID

os-win32.c

+16
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
#include "sysemu/sysemu.h"
3333
#include "qemu-options.h"
3434

35+
#ifdef CONFIG_ANDROID
36+
#include "android/skin/winsys.h"
37+
#endif
38+
3539
/***********************************************************/
3640
/* Functions missing in mingw */
3741

@@ -49,7 +53,19 @@ int setenv(const char *name, const char *value, int overwrite)
4953

5054
static BOOL WINAPI qemu_ctrl_handler(DWORD type)
5155
{
56+
#ifdef CONFIG_ANDROID
57+
// In android, request closing the UI, instead of short-circuting down to
58+
// qemu. This will eventually call qemu_system_shutdown_request via a skin
59+
// event.
60+
skin_winsys_quit_request();
61+
// Windows 7 kills application when the function returns.
62+
// Sleep here to give QEMU a try for closing.
63+
// Sleep period is 10000ms because Windows kills the program
64+
// after 10 seconds anyway.
65+
Sleep(10000);
66+
#else
5267
exit(STATUS_CONTROL_C_EXIT);
68+
#endif // !CONFIG_ANDROID
5369
return TRUE;
5470
}
5571

0 commit comments

Comments
 (0)