From patchwork Tue May 28 23:51:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 247062 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6ACF62C033F for ; Wed, 29 May 2013 09:52:49 +1000 (EST) Received: from localhost ([::1]:37098 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhTh9-0006kd-MT for incoming@patchwork.ozlabs.org; Tue, 28 May 2013 19:52:47 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49720) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhTfv-0004qS-2P for qemu-devel@nongnu.org; Tue, 28 May 2013 19:51:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UhTfu-00039b-2W for qemu-devel@nongnu.org; Tue, 28 May 2013 19:51:30 -0400 Received: from mout.web.de ([212.227.17.12]:54092) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhTft-00039L-OX for qemu-devel@nongnu.org; Tue, 28 May 2013 19:51:30 -0400 Received: from localhost.localdomain ([84.148.9.73]) by smtp.web.de (mrweb001) with ESMTPSA (Nemesis) id 0MNLAn-1UnpSQ0oHp-007W7d; Wed, 29 May 2013 01:51:27 +0200 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Wed, 29 May 2013 01:51:21 +0200 Message-Id: <1369785081-4838-5-git-send-email-andreas.faerber@web.de> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1369785081-4838-1-git-send-email-andreas.faerber@web.de> References: <1369785081-4838-1-git-send-email-andreas.faerber@web.de> MIME-Version: 1.0 X-Provags-ID: V02:K0:rPdtOXETravKb19pvU2IwHo3t6EzgixneGRnX23HX+7 ADrh5a4DaGtCZ0dE9+NIGLUzqjyuxIzC7SVnQfolAYUA3u1a/g pTkOcbkN4UM0c4xYcOcNvxh7KfPSKwn4gYeEzBEM1Vf1eGN/TN ylZWk3aqdKTs2yA2LkLym+KHkmKR+4DDTHvX8nlk6rzzsJGmd9 eleR9EaWFFSoxQqNaK1Sg== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 212.227.17.12 Cc: Peter Maydell , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Anthony Liguori Subject: [Qemu-devel] [PULL 4/4] cocoa: Avoid deprecated NSOpenPanel beginSheetForDirectory 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 From: Peter Maydell In MacOSX 10.6 and above the NSOpenPanel beginSheetForDirectory method is deprecated. Use the preferred replacements instead. We retain the original code for use on earlier MacOSX versions because the replacement methods don't exist before 10.6. Signed-off-by: Peter Maydell Signed-off-by: Andreas Färber --- ui/cocoa.m | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index bb59511..be49179 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -35,6 +35,9 @@ #ifndef MAC_OS_X_VERSION_10_5 #define MAC_OS_X_VERSION_10_5 1050 #endif +#ifndef MAC_OS_X_VERSION_10_6 +#define MAC_OS_X_VERSION_10_6 1060 +#endif //#define DEBUG @@ -771,9 +774,20 @@ QemuCocoaView *cocoaView; 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"]; - [op beginSheetForDirectory:nil file:nil types:[NSArray arrayWithObjects:@"img",@"iso",@"dmg",@"qcow",@"cow",@"cloop",@"vmdk",nil] + NSArray *filetypes = [NSArray arrayWithObjects:@"img", @"iso", @"dmg", + @"qcow", @"cow", @"cloop", @"vmdk", nil]; +#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6) + [op setAllowedFileTypes:filetypes]; + [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];