From d15cb0660c35bcab7505ffbe10dd9656b71a49ac Mon Sep 17 00:00:00 2001 From: Phillipus Date: Wed, 15 May 2024 11:57:48 +0100 Subject: [PATCH] Fix warning message on Mac about secure coding not enabled - See https://github.com/eclipse-equinox/equinox/issues/630 - On macOS 14 and later a warning message is written to console: "WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES." - This adds an NSApplicationDelegate that implements applicationSupportsSecureRestorableState --- .../library/cocoa/eclipseCocoa.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/features/org.eclipse.equinox.executable.feature/library/cocoa/eclipseCocoa.c b/features/org.eclipse.equinox.executable.feature/library/cocoa/eclipseCocoa.c index 43f2b7a2eb6..eec8f79a85f 100644 --- a/features/org.eclipse.equinox.executable.feature/library/cocoa/eclipseCocoa.c +++ b/features/org.eclipse.equinox.executable.feature/library/cocoa/eclipseCocoa.c @@ -83,6 +83,16 @@ static const char* jvmLibs[] = { "libjvm.dylib", "libjvm.jnilib", "libjvm.so", N /* Define the window system arguments for the various Java VMs. */ static char* argVM_JAVA[] = { "-XstartOnFirstThread", NULL }; +@interface AppDelegate : NSObject +- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app; +@end + +@implementation AppDelegate +- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app { + return YES; +} +@end + static NSWindow* window = nil; @interface KeyWindow : NSWindow { } - (BOOL)canBecomeKeyWindow; @@ -106,7 +116,7 @@ static NSWindow* window = nil; int result = ENOENT; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - [NSApplication sharedApplication]; + [[NSApplication sharedApplication] setDelegate: [[AppDelegate alloc] init]]; NSImage* image = [[NSImage alloc] initByReferencingFile: featureImage]; [featureImage release]; if (image != NULL) {