@@ -116,8 +116,9 @@ + (ApplicationDelegate *)sharedDelegate {
116
116
117
117
// don't install the EAWT delegate if another kind of NSApplication is installed, like say, Safari
118
118
BOOL shouldInstall = NO ;
119
+ BOOL overrideDelegate = (getenv (" AWT_OVERRIDE_NSDELEGATE" ) != NULL );
119
120
if (NSApp != nil ) {
120
- if ([NSApp isMemberOfClass: [NSApplication class ]]) shouldInstall = YES ;
121
+ if ([NSApp isMemberOfClass: [NSApplication class ]] && overrideDelegate ) shouldInstall = YES ;
121
122
if ([NSApp isKindOfClass: [NSApplicationAWT class ]]) shouldInstall = YES ;
122
123
}
123
124
checked = YES ;
@@ -409,6 +410,19 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)app {
409
410
return NSTerminateLater;
410
411
}
411
412
413
+ - (BOOL )applicationSupportsSecureRestorableState : (NSApplication *)app {
414
+ static BOOL checked = NO ;
415
+ static BOOL supportsSecureState = YES ;
416
+
417
+ if (checked == NO ) {
418
+ checked = YES ;
419
+ if (getenv (" AWT_DISABLE_NSDELEGATE_SECURE_SAVE" ) != NULL ) {
420
+ supportsSecureState = NO ;
421
+ }
422
+ }
423
+ return supportsSecureState;
424
+ }
425
+
412
426
+ (void )_systemWillPowerOff {
413
427
[self _notifyJava: com_apple_eawt__AppEventHandler_NOTIFY_SHUTDOWN];
414
428
}
@@ -506,8 +520,10 @@ + (void)_setDockIconImage:(NSImage *)image {
506
520
[dockImageView setImageScaling: NSImageScaleProportionallyUpOrDown];
507
521
[dockImageView setImage: image];
508
522
509
- [[ApplicationDelegate sharedDelegate ].fProgressIndicator removeFromSuperview ];
510
- [dockImageView addSubview: [ApplicationDelegate sharedDelegate ].fProgressIndicator];
523
+ if ([ApplicationDelegate sharedDelegate ] != nil ) {
524
+ [[ApplicationDelegate sharedDelegate ].fProgressIndicator removeFromSuperview ];
525
+ [dockImageView addSubview: [ApplicationDelegate sharedDelegate ].fProgressIndicator];
526
+ }
511
527
512
528
// add it to the NSDockTile
513
529
[dockTile setContentView: dockImageView];
@@ -520,14 +536,15 @@ + (void)_setDockIconProgress:(NSNumber *)value {
520
536
AWT_ASSERT_APPKIT_THREAD;
521
537
522
538
ApplicationDelegate *delegate = [ApplicationDelegate sharedDelegate ];
523
- if ([value doubleValue ] >= 0 && [value doubleValue ] <=100 ) {
524
- [delegate.fProgressIndicator setDoubleValue: [value doubleValue ]];
525
- [delegate.fProgressIndicator setHidden: NO ];
526
- } else {
527
- [delegate.fProgressIndicator setHidden: YES ];
539
+ if (delegate != nil ) {
540
+ if ([value doubleValue ] >= 0 && [value doubleValue ] <=100 ) {
541
+ [delegate.fProgressIndicator setDoubleValue: [value doubleValue ]];
542
+ [delegate.fProgressIndicator setHidden: NO ];
543
+ } else {
544
+ [delegate.fProgressIndicator setHidden: YES ];
545
+ }
546
+ [[NSApp dockTile ] display ];
528
547
}
529
-
530
- [[NSApp dockTile ] display ];
531
548
}
532
549
533
550
// Obtains the image of the Dock icon, either manually set, a drawn copy, or the default NSApplicationIcon
@@ -638,7 +655,9 @@ + (NSImage *)_dockIconImage {
638
655
639
656
NSMenu *menu = (NSMenu *)jlong_to_ptr (nsMenuPtr);
640
657
[ThreadUtilities performOnMainThreadWaiting: YES block: ^(){
641
- [ApplicationDelegate sharedDelegate ].fDockMenu = menu;
658
+ if ([ApplicationDelegate sharedDelegate ] != nil ) {
659
+ [ApplicationDelegate sharedDelegate ].fDockMenu = menu;
660
+ }
642
661
}];
643
662
644
663
JNI_COCOA_EXIT (env);
@@ -818,13 +837,15 @@ + (NSImage *)_dockIconImage {
818
837
819
838
[ThreadUtilities performOnMainThreadWaiting: NO block: ^(){
820
839
ApplicationDelegate *delegate = [ApplicationDelegate sharedDelegate ];
821
- switch (menuID) {
822
- case com_apple_eawt__AppMenuBarHandler_MENU_ABOUT:
823
- [delegate _updateAboutMenu: visible enabled: enabled];
824
- break ;
825
- case com_apple_eawt__AppMenuBarHandler_MENU_PREFS:
826
- [delegate _updatePreferencesMenu: visible enabled: enabled];
827
- break ;
840
+ if (delegate != nil ) {
841
+ switch (menuID) {
842
+ case com_apple_eawt__AppMenuBarHandler_MENU_ABOUT:
843
+ [delegate _updateAboutMenu: visible enabled: enabled];
844
+ break ;
845
+ case com_apple_eawt__AppMenuBarHandler_MENU_PREFS:
846
+ [delegate _updatePreferencesMenu: visible enabled: enabled];
847
+ break ;
848
+ }
828
849
}
829
850
}];
830
851
@@ -843,7 +864,9 @@ + (NSImage *)_dockIconImage {
843
864
844
865
CMenuBar *menu = (CMenuBar *)jlong_to_ptr (cMenuBarPtr);
845
866
[ThreadUtilities performOnMainThreadWaiting: NO block: ^(){
846
- [ApplicationDelegate sharedDelegate ].fDefaultMenuBar = menu;
867
+ if ([ApplicationDelegate sharedDelegate ] != nil ) {
868
+ [ApplicationDelegate sharedDelegate ].fDefaultMenuBar = menu;
869
+ }
847
870
}];
848
871
849
872
JNI_COCOA_EXIT (env);
1 commit comments
openjdk-notifier[bot] commentedon Apr 25, 2024
Review
Issues