Use NSWorkspace inforForExcetsion to check if current registred HelpViewer is capable of showing the Help File, otherwise fall-back to NSWorkspace open as if no HelpViewer is set

This commit is contained in:
Riccardo Mottola 2025-04-01 00:29:15 +02:00
parent 4faee2de0b
commit 0db5a24849

View file

@ -215,27 +215,16 @@
{
if (viewer && [viewer length] > 0)
{
NSBundle *appBundle = [ws bundleForApp: viewer];
NSArray *types;
NSMutableArray *extensions = [NSMutableArray array];
NSDictionary *apps = [ws infoForExtension: ext];
NSDictionary *appInfo;
types = [appBundle objectForInfoDictionaryKey:@"NSTypes"];
if (types)
{
NSUInteger i;
// Let's try to be lenient if Viewer was set instead of Viewer.app
if ([[viewer pathExtension] length] == 0)
viewer = [viewer stringByAppendingPathExtension:@"app"];
appInfo = [apps objectForKey: viewer];
for (i = 0; i < [types count]; i++)
{
NSArray *unixExtensions;
NSUInteger j;
unixExtensions = [[types objectAtIndex: i] objectForKey:@"NSUnixExtensions"];
for (j = 0; j < [unixExtensions count]; j++)
[extensions addObject: [[unixExtensions objectAtIndex:j] lowercaseString]];
}
}
if (![extensions containsObject:[ext lowercaseString]])
// We ingore the role, supposing both Editor and Viewer are fine
if (nil == appInfo)
{
NSWarnLog(@"Designated viewer %@ is not registered for %@", viewer, ext);
viewer = nil;