Skip to content

Commit e18bd28

Browse files
Phillipusamartya4256
authored andcommitted
Fix warning message on Mac about secure coding not enabled (eclipse-platform#1231)
- See eclipse-platform#1228 - 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." - As recommended by Apple, this change adds a new selector for applicationSupportsSecureRestorableState and returns a 1 value (YES) in the callback in the Display class - However, this only takes care of the NSApplicationDelegate created in the Display class. The warning message will still appear when a splash screen is created in Equinox JNI code so a fix there is also required. See eclipse-equinox/equinox#630 - This implementation for SWT can be tested by using the -noSplash argument when launching Eclipse
1 parent 481d8b1 commit e18bd28

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,9 @@ public static int VERSION (int major, int minor, int bugfix) {
156156
public static final long sel_setStyle = Selector.sel_setStyle.value;
157157
public static final int NSTableViewStylePlain = 4;
158158

159-
/** 14.0 selector */
160-
public static final long sel_setClipsToBounds_ = Selector.sel_setClipsToBounds_.value;
159+
/** 14.0 selectors */
160+
public static final long sel_setClipsToBounds_ = Selector.sel_setClipsToBounds_.value;
161+
public static final long sel_applicationSupportsSecureRestorableState_ = Selector.sel_applicationSupportsSecureRestorableState_.value;
161162

162163
/* AWT application delegate. Remove these when JavaRuntimeSupport.framework has bridgesupport generated for it. */
163164
public static final long class_JRSAppKitAWT = objc_getClass("JRSAppKitAWT");

bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ public enum Selector {
8282
/** 11.0 selector */
8383
, sel_setStyle("setStyle:")
8484

85-
/** 14.0 selector */
85+
/** 14.0 selectors */
8686
, sel_setClipsToBounds_("setClipsToBounds:")
87+
, sel_applicationSupportsSecureRestorableState_("applicationSupportsSecureRestorableState:")
8788

8889
, sel_awtAppDelegate("awtAppDelegate")
8990

bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,7 @@ void createDisplay (DeviceData data) {
10521052
OS.class_addMethod(cls, OS.sel_application_openUrls_, appProc4, "@:@@");
10531053
OS.class_addMethod(cls, OS.sel_applicationShouldHandleReopen_hasVisibleWindows_, appProc4, "@:@B");
10541054
OS.class_addMethod(cls, OS.sel_applicationShouldTerminate_, appProc3, "@:@");
1055+
OS.class_addMethod(cls, OS.sel_applicationSupportsSecureRestorableState_, appProc3, "@:@");
10551056
OS.objc_registerClassPair(cls);
10561057
}
10571058

@@ -5902,6 +5903,9 @@ static long applicationProc(long id, long sel, long arg0) {
59025903
}
59035904
return 0;
59045905
}
5906+
case sel_applicationSupportsSecureRestorableState_: {
5907+
return 1;
5908+
}
59055909
default: {
59065910
return 0;
59075911
}

0 commit comments

Comments
 (0)