From patchwork Fri Sep 18 18:32:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 519512 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6345C140216 for ; Sat, 19 Sep 2015 04:32:55 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=ywOuF1Im; dkim-atps=neutral Received: from localhost ([::1]:41122 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zd0Sr-0001Kk-A4 for incoming@patchwork.ozlabs.org; Fri, 18 Sep 2015 14:32:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zd0SZ-00011k-9A for qemu-devel@nongnu.org; Fri, 18 Sep 2015 14:32:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zd0SV-0000Rz-7J for qemu-devel@nongnu.org; Fri, 18 Sep 2015 14:32:35 -0400 Received: from mail-qg0-x236.google.com ([2607:f8b0:400d:c04::236]:35215) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zd0SV-0000Rr-1V for qemu-devel@nongnu.org; Fri, 18 Sep 2015 14:32:31 -0400 Received: by qgt47 with SMTP id 47so45689299qgt.2 for ; Fri, 18 Sep 2015 11:32:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:subject:date:message-id:cc:to:mime-version; bh=e+SDiqQKRPnJBFwmUgRK2xOWBOLnRDOtbi5lVBCfWWo=; b=ywOuF1ImiepdsR41Qw12NV5xpef2TMUIUeKZoq3azQZJfjoJ9uSaJBUPtCL6TTGSLf pBli/C+h+j4cIm1MYIkJD0Bh5WtY0vfnV29PkWN4aoikAL75ElSKntH7WYNsM1NCnvm2 5fSoLZvjUU77VpU94rVVjswjd9Xb+sISsyuxY71A8JVTl5LRYo/Qq1NZxeBdCvMoK3M1 7pAc5jYkF4n3veENOurOtMPOOrZIUQ/3CzhtVBpJZuBPMxrCPBvsu0VXe+II4GHF/TRF bVS4cQWTFMYxTzbhA4401uXUWj9KPJs+gBYFYqRcdhEh8iT78HOVNKan3v7wLxlh9uAd JE+Q== X-Received: by 10.140.131.134 with SMTP id 128mr8673674qhd.44.1442601150709; Fri, 18 Sep 2015 11:32:30 -0700 (PDT) Received: from [192.168.0.3] (d199-74-164-53.col.wideopenwest.com. [74.199.53.164]) by smtp.gmail.com with ESMTPSA id o89sm4147396qkh.4.2015.09.18.11.32.29 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Sep 2015 11:32:29 -0700 (PDT) From: Programmingkid Date: Fri, 18 Sep 2015 14:32:28 -0400 Message-Id: To: Peter Maydell Mime-Version: 1.0 (Apple Message framework v1084) X-Mailer: Apple Mail (2.1084) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c04::236 Cc: qemu-devel qemu-devel Subject: [Qemu-devel] [PATCH] ui/cocoa.m: Make boot image loading code compatible with GCC 4.9 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org When QEMU is launched on Mac OS X without any arguments, an open file dialog appears. The user is then expected to select a file to boot QEMU with. This code was not compatible with GCC 4.9 (user-built, not Apple supplied). This patch greatly simplifes the open file dialog feature and makes it compatible with GCC 4.9. Signed-off-by: John Arbuckle --- ui/cocoa.m | 59 +++++++++++++---------------------------------------------- 1 files changed, 13 insertions(+), 46 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 334e6f6..3b33094 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -814,7 +814,6 @@ QemuCocoaView *cocoaView; { } - (void)startEmulationWithArgc:(int)argc argv:(char**)argv; -- (void)openPanelDidEnd:(NSOpenPanel *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo; - (void)doToggleFullScreen:(id)sender; - (void)toggleFullScreen:(id)sender; - (void)showQEMUDoc:(id)sender; @@ -901,23 +900,21 @@ QemuCocoaView *cocoaView; if( gArgc <= 1 || strncmp ((char *)gArgv[1], "-psn", 4) == 0) { NSOpenPanel *op = [[NSOpenPanel alloc] init]; [op setPrompt:@"Boot image"]; - [op setMessage:@"Select the disk image you want to boot.\n\nHit the \"Cancel\" button to quit"]; -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6) + [op setMessage:@"Select the disk image you want to boot.\n"]; [op setAllowedFileTypes:supportedImageFileTypes]; - [op beginSheetModalForWindow:normalWindow - completionHandler:^(NSInteger returnCode) - { [self openPanelDidEnd:op - returnCode:returnCode contextInfo:NULL ]; } ]; -#else - // Compatibility code for pre-10.6, using deprecated method - [op beginSheetForDirectory:nil file:nil types:filetypes - modalForWindow:normalWindow modalDelegate:self - didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:) contextInfo:NULL]; -#endif - } else { - // or launch QEMU, with the global args - [self startEmulationWithArgc:gArgc argv:(char **)gArgv]; + if([op runModal] == NSFileHandlingPanelOKButton) { + /* Boot QEMU with selected image */ + const char *file_path = [[[op URL] path] cStringUsingEncoding: + NSASCIIStringEncoding]; + char *appName = g_strdup(gArgv[0]); + gArgv = g_new(char *, 3); + gArgv[0] = appName; + gArgv[1] = g_strdup("-hda"); + gArgv[2] = g_strdup(file_path); + gArgc = 3; + } } + [self startEmulationWithArgc:gArgc argv:(char **)gArgv]; } - (void)applicationWillTerminate:(NSNotification *)aNotification @@ -942,36 +939,6 @@ QemuCocoaView *cocoaView; exit(status); } -- (void)openPanelDidEnd:(NSOpenPanel *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo -{ - COCOA_DEBUG("QemuCocoaAppController: openPanelDidEnd\n"); - - /* The NSFileHandlingPanelOKButton/NSFileHandlingPanelCancelButton values for - * returnCode strictly only apply for the 10.6-and-up beginSheetModalForWindow - * API. For the legacy pre-10.6 beginSheetForDirectory API they are NSOKButton - * and NSCancelButton. However conveniently the values are the same. - * We use the non-legacy names because the others are deprecated in OSX 10.10. - */ - if (returnCode == NSFileHandlingPanelCancelButton) { - exit(0); - } else if (returnCode == NSFileHandlingPanelOKButton) { - char *img = (char*)[ [ [ sheet URL ] path ] cStringUsingEncoding:NSASCIIStringEncoding]; - - char **argv = g_new(char *, 4); - - [sheet close]; - - 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, gArgv[0], img); - - [self startEmulationWithArgc:3 argv:(char**)argv]; - } -} - /* We abstract the method called by the Enter Fullscreen menu item * because Mac OS 10.7 and higher disables it. This is because of the * menu item's old selector's name toggleFullScreen: