diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2013-12-08 22:59:06 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2014-01-12 22:27:10 +0000 |
commit | 98db429d2c6d157b7e00e3f24b6b1d9036f5e358 (patch) | |
tree | 07ce50fa80ae4c6805b2eec9d779d07b0f1077c5 | |
parent | 5342f990f46512487e3e5be1047a5b424f00d255 (diff) | |
download | qemu-98db429d2c6d157b7e00e3f24b6b1d9036f5e358.zip qemu-98db429d2c6d157b7e00e3f24b6b1d9036f5e358.tar.gz qemu-98db429d2c6d157b7e00e3f24b6b1d9036f5e358.tar.bz2 |
ui/cocoa: Fix code for starting QEMU via image file load dialog
Fix a number of bugs in the code for starting QEMU via the image
file load dialog:
* use the actual argv[0] rather than "qemu": this avoids failures to
find BIOS image files caused by not looking in the correct directory
relative to the executable path
* allocate a large enough argv array to NULL terminate it
* use g_strdup(X) rather than g_strdup_printf("%s", X) or
g_strdup_printf(X)
* disable the printing of the simulated command line argument
(which is presumably intended for debug only)
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1386543546-31919-6-git-send-email-peter.maydell@linaro.org
-rw-r--r-- | ui/cocoa.m | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -833,18 +833,18 @@ QemuCocoaView *cocoaView; if(returnCode == NSCancelButton) { exit(0); } else if(returnCode == NSOKButton) { - const char *bin = "qemu"; char *img = (char*)[ [ [ sheet URL ] path ] cStringUsingEncoding:NSASCIIStringEncoding]; - char **argv = (char**)malloc( sizeof(char*)*3 ); + char **argv = g_new(char *, 4); [sheet close]; - argv[0] = g_strdup_printf("%s", bin); - argv[1] = g_strdup_printf("-hda"); - argv[2] = g_strdup_printf("%s", img); + argv[0] = g_strdup(gArgv[0]); + argv[1] = g_strdup("-hda"); + argv[2] = g_strdup(img); + argv[3] = NULL; - printf("Using argc %d argv %s -hda %s\n", 3, bin, img); + // printf("Using argc %d argv %s -hda %s\n", 3, gArgv[0], img); [self startEmulationWithArgc:3 argv:(char**)argv]; } |