From f8df6ba27115431c103432350c7f6381a6512fc7 Mon Sep 17 00:00:00 2001 From: Greg Lucas Date: Thu, 18 Jan 2024 19:22:39 -0700 Subject: [PATCH] MNT: Implement macos AppDelegate This suppresses a warning that appears with MacOS 14+. WARNING: Secure coding is not enabled for restorable state! --- src/_macosx.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/_macosx.m b/src/_macosx.m index ac9009965b4f..8038b72899df 100755 --- a/src/_macosx.m +++ b/src/_macosx.m @@ -100,6 +100,9 @@ static int wait_for_stdin() { } /* ---------------------------- Cocoa classes ---------------------------- */ +@interface MatplotlibAppDelegate : NSObject +- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app; +@end @interface Window : NSWindow { PyObject* manager; @@ -195,6 +198,7 @@ static void lazy_init(void) { NSApp = [NSApplication sharedApplication]; [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; + [NSApp setDelegate: [[[MatplotlibAppDelegate alloc] init] autorelease]]; // Run our own event loop while waiting for stdin on the Python side // this is needed to keep the application responsive while waiting for input @@ -779,6 +783,12 @@ int mpl_check_modifier( }, }; +@implementation MatplotlibAppDelegate +- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app { + return YES; +} +@end + @interface NavigationToolbar2Handler : NSObject { PyObject* toolbar; NSButton* panbutton;