* [PATCH] ui/cocoa: Fix openFile: deprecation on Big Sur
@ 2021-01-02 12:51 Roman Bolshakov
2021-01-02 13:16 ` Peter Maydell
0 siblings, 1 reply; 3+ messages in thread
From: Roman Bolshakov @ 2021-01-02 12:51 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Roman Bolshakov, Gerd Hoffmann
ui/cocoa.m:1188:44: warning: 'openFile:' is deprecated: first deprecated in macOS 11.0 - Use -[NSWorkspace openURL:] instead.
[-Wdeprecated-declarations]
if ([[NSWorkspace sharedWorkspace] openFile: full_file_path] == YES) {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSWorkspace.h:350:1: note:
'openFile:' has been explicitly marked deprecated here
- (BOOL)openFile:(NSString *)fullPath API_DEPRECATED("Use -[NSWorkspace openURL:] instead.", macos(10.0, 11.0));
^
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
---
ui/cocoa.m | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/ui/cocoa.m b/ui/cocoa.m
index f32adc3074..5909758a09 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -1178,6 +1178,7 @@ QemuCocoaView *cocoaView;
/* Where to look for local files */
NSString *path_array[] = {@"../share/doc/qemu/", @"../doc/qemu/", @"../docs/"};
NSString *full_file_path;
+ NSURL *full_file_url;
/* iterate thru the possible paths until the file is found */
int index;
@@ -1186,7 +1187,8 @@ QemuCocoaView *cocoaView;
full_file_path = [full_file_path stringByDeletingLastPathComponent];
full_file_path = [NSString stringWithFormat: @"%@/%@%@", full_file_path,
path_array[index], filename];
- if ([[NSWorkspace sharedWorkspace] openFile: full_file_path] == YES) {
+ full_file_url = [NSURL URLWithString: full_file_path];
+ if ([[NSWorkspace sharedWorkspace] openURL: full_file_url] == YES) {
return;
}
}
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] ui/cocoa: Fix openFile: deprecation on Big Sur
2021-01-02 12:51 [PATCH] ui/cocoa: Fix openFile: deprecation on Big Sur Roman Bolshakov
@ 2021-01-02 13:16 ` Peter Maydell
2021-01-02 14:20 ` Roman Bolshakov
0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2021-01-02 13:16 UTC (permalink / raw)
To: Roman Bolshakov; +Cc: QEMU Developers, Gerd Hoffmann
On Sat, 2 Jan 2021 at 12:52, Roman Bolshakov <r.bolshakov@yadro.com> wrote:
>
> ui/cocoa.m:1188:44: warning: 'openFile:' is deprecated: first deprecated in macOS 11.0 - Use -[NSWorkspace openURL:] instead.
> [-Wdeprecated-declarations]
> if ([[NSWorkspace sharedWorkspace] openFile: full_file_path] == YES) {
> ^
> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSWorkspace.h:350:1: note:
> 'openFile:' has been explicitly marked deprecated here
> - (BOOL)openFile:(NSString *)fullPath API_DEPRECATED("Use -[NSWorkspace openURL:] instead.", macos(10.0, 11.0));
> ^
>
> Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
> ---
> ui/cocoa.m | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index f32adc3074..5909758a09 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -1178,6 +1178,7 @@ QemuCocoaView *cocoaView;
> /* Where to look for local files */
> NSString *path_array[] = {@"../share/doc/qemu/", @"../doc/qemu/", @"../docs/"};
> NSString *full_file_path;
> + NSURL *full_file_url;
>
> /* iterate thru the possible paths until the file is found */
> int index;
> @@ -1186,7 +1187,8 @@ QemuCocoaView *cocoaView;
> full_file_path = [full_file_path stringByDeletingLastPathComponent];
> full_file_path = [NSString stringWithFormat: @"%@/%@%@", full_file_path,
> path_array[index], filename];
> - if ([[NSWorkspace sharedWorkspace] openFile: full_file_path] == YES) {
> + full_file_url = [NSURL URLWithString: full_file_path];
> + if ([[NSWorkspace sharedWorkspace] openURL: full_file_url] == YES) {
> return;
> }
The NSURL URLWithString method documentation:
https://developer.apple.com/documentation/foundation/nsurl/1572047-urlwithstring
says:
# Important
# To create NSURL objects for file system paths, use
fileURLWithPath:isDirectory:
# instead.
Should we be doing that instead ?
thanks
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ui/cocoa: Fix openFile: deprecation on Big Sur
2021-01-02 13:16 ` Peter Maydell
@ 2021-01-02 14:20 ` Roman Bolshakov
0 siblings, 0 replies; 3+ messages in thread
From: Roman Bolshakov @ 2021-01-02 14:20 UTC (permalink / raw)
To: Peter Maydell; +Cc: QEMU Developers, Gerd Hoffmann
On Sat, Jan 02, 2021 at 01:16:48PM +0000, Peter Maydell wrote:
> On Sat, 2 Jan 2021 at 12:52, Roman Bolshakov <r.bolshakov@yadro.com> wrote:
> >
> > ui/cocoa.m:1188:44: warning: 'openFile:' is deprecated: first deprecated in macOS 11.0 - Use -[NSWorkspace openURL:] instead.
> > [-Wdeprecated-declarations]
> > if ([[NSWorkspace sharedWorkspace] openFile: full_file_path] == YES) {
> > ^
> > /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSWorkspace.h:350:1: note:
> > 'openFile:' has been explicitly marked deprecated here
> > - (BOOL)openFile:(NSString *)fullPath API_DEPRECATED("Use -[NSWorkspace openURL:] instead.", macos(10.0, 11.0));
> > ^
> >
> > Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
> > ---
> > ui/cocoa.m | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/ui/cocoa.m b/ui/cocoa.m
> > index f32adc3074..5909758a09 100644
> > --- a/ui/cocoa.m
> > +++ b/ui/cocoa.m
> > @@ -1178,6 +1178,7 @@ QemuCocoaView *cocoaView;
> > /* Where to look for local files */
> > NSString *path_array[] = {@"../share/doc/qemu/", @"../doc/qemu/", @"../docs/"};
> > NSString *full_file_path;
> > + NSURL *full_file_url;
> >
> > /* iterate thru the possible paths until the file is found */
> > int index;
> > @@ -1186,7 +1187,8 @@ QemuCocoaView *cocoaView;
> > full_file_path = [full_file_path stringByDeletingLastPathComponent];
> > full_file_path = [NSString stringWithFormat: @"%@/%@%@", full_file_path,
> > path_array[index], filename];
> > - if ([[NSWorkspace sharedWorkspace] openFile: full_file_path] == YES) {
> > + full_file_url = [NSURL URLWithString: full_file_path];
> > + if ([[NSWorkspace sharedWorkspace] openURL: full_file_url] == YES) {
> > return;
> > }
>
> The NSURL URLWithString method documentation:
> https://developer.apple.com/documentation/foundation/nsurl/1572047-urlwithstring
> says:
> # Important
> # To create NSURL objects for file system paths, use
> fileURLWithPath:isDirectory:
> # instead.
>
> Should we be doing that instead ?
>
Sure, Peter. I'll update it.
Thanks,
Roman
> thanks
> -- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-02 14:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-02 12:51 [PATCH] ui/cocoa: Fix openFile: deprecation on Big Sur Roman Bolshakov
2021-01-02 13:16 ` Peter Maydell
2021-01-02 14:20 ` Roman Bolshakov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).