Please add fallback to use arrow cursor:
+ (void) initialize {
if (self == [ScintillaView class]) {
NSBundle *bundle = [NSBundle bundleForClass: [ScintillaView class]];
NSString *path = [bundle pathForResource: @"mac_cursor_busy" ofType: @"tiff" inDirectory: nil];
NSImage *image = [[NSImage alloc] initWithContentsOfFile: path];
if (image) {
waitCursor = [[NSCursor alloc] initWithImage: image hotSpot: NSMakePoint(2, 2)];
} else {
NSLog(@"Wait cursor is invalid.");
waitCursor = [[NSCursor arrow] retain];
}
path = [bundle pathForResource: @"mac_cursor_flipped" ofType: @"tiff" inDirectory: nil];
image = [[NSImage alloc] initWithContentsOfFile: path];
if (image) {
reverseArrowCursor = [[NSCursor alloc] initWithImage: image hotSpot: NSMakePoint(15, 2)];
} else {
NSLog(@"Reverse arrow cursor is invalid.");
reverseArrowCursor = [[NSCursor arrow] retain];
}
}
}
This may prevent crashes when the cursor is nil.
Since ARC is used, the retain is not needed:
Last edit: Christian Schmitz 2021-12-14
The underlying problem is that the image couldn't be loaded and this should be fixed instead of working around it.
Cursor image loading was supposed to be fixed by [16f92e].
Related
Commit: [16f92e]
Well, we like to use Scintilla in our app and I'd like to make sure that the images are optional, so this can work without them.
So please include a fallback for that case like the two lines above..
Are you using the provided Scintilla.xcodeproj project file?
Sure. I use it to build myself a library.
And if the waitCursor/reverseArrowCursor would not be static, we could just prefill them on application start.
The images should be loaded on ScintillaView class load (+initialize) which occurs when Scintilla is loaded.
I just don't understand why the image resources aren't available.
Because we build a library, which others use and they may not include the images.
And the software should in my opinion simply work without them.
its unclear what you mean here. Is this a static library? Scintilla.xcodeproj builds a framework, which is a shared library plus resources (such as these images) and headers. Why wouldn't the images be included? The 'info bar' feature will also fail if its image isn't available.
Are you deliberately removing the images because you do not like these cursors?
We changed the project to build a static library.
The info bar can work fine without the image.
For my project, I include the images, but I don't like it to crash if the user forgets the pictures.
Committed as [70ba51].
Future changes to Scintilla may add more resources which could cause crashes if not included in builds.
Related
Commit: [70ba51]