From cd8741f638ab6e0567ceaa63b2a5d0d61880365d Mon Sep 17 00:00:00 2001 From: Vlad Borovtsov Date: Sun, 30 Nov 2025 23:33:08 +0100 Subject: [PATCH] Fix rendering without hosting view on macOS --- framework/Source/CPTLayer.m | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/framework/Source/CPTLayer.m b/framework/Source/CPTLayer.m index aa6cd5bcb..18324d89b 100644 --- a/framework/Source/CPTLayer.m +++ b/framework/Source/CPTLayer.m @@ -330,23 +330,29 @@ -(void)display if ( [NSView instancesRespondToSelector:@selector(effectiveAppearance)] ) { CPTGraphHostingView *hostingView = [self findHostingView]; - if ( [NSAppearance instancesRespondToSelector:@selector(performAsCurrentDrawingAppearance:)] ) { + NSAppearance *appearance = hostingView.effectiveAppearance; + + if ( appearance && [NSAppearance instancesRespondToSelector:@selector(performAsCurrentDrawingAppearance:)] ) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunguarded-availability-new" - [hostingView.effectiveAppearance performAsCurrentDrawingAppearance: ^{ + [appearance performAsCurrentDrawingAppearance: ^{ [super display]; }]; #pragma clang diagnostic pop } - else { + else if ( appearance ) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" NSAppearance *oldAppearance = NSAppearance.currentAppearance; - NSAppearance.currentAppearance = hostingView.effectiveAppearance; + NSAppearance.currentAppearance = appearance; [super display]; NSAppearance.currentAppearance = oldAppearance; #pragma clang diagnostic pop } + else { + // No hosting view; fall back to the default rendering path so the layer still draws. + [super display]; + } } else { [super display];