Replace deprecated LSGetApplicationForInfo()

This commit is contained in:
Stefan Csomor
2020-07-09 16:11:14 +02:00
committed by Vadim Zeitlin
parent c53e9d913b
commit 7be80a858d

View File

@@ -426,16 +426,14 @@ void wxMimeTypesManagerImpl::LoadDisplayDataForUti(const wxString& uti)
const static wxCFStringRef descKey( "CFBundleTypeName" ); const static wxCFStringRef descKey( "CFBundleTypeName" );
const static wxCFStringRef iconKey( "CFBundleTypeIconFile" ); const static wxCFStringRef iconKey( "CFBundleTypeIconFile" );
// The call for finding the preferred application for a UTI is LSCopyDefaultRoleHandlerForContentType wxCFStringRef cfuti(uti);
// This returns an empty string on OS X 10.5
// Instead it is necessary to get the primary extension and use LSGetApplicationForInfo wxCFStringRef ext = UTTypeCopyPreferredTagWithClass( cfuti, kUTTagClassFilenameExtension );
wxCFStringRef ext = UTTypeCopyPreferredTagWithClass( wxCFStringRef( uti ), kUTTagClassFilenameExtension );
// Look up the preferred application // Look up the preferred application
CFURLRef appUrl; wxCFRef<CFURLRef> appUrl = LSCopyDefaultApplicationURLForContentType( cfuti, kLSRolesAll, NULL);
OSStatus status = LSGetApplicationForInfo( kLSUnknownType, kLSUnknownCreator, ext, kLSRolesAll, NULL, &appUrl );
if( status != noErr ) if( !appUrl )
return; return;
// Create a bundle object for that application // Create a bundle object for that application