changeset 17591:02afb762b2bf

8162840: Desktop. enableSuddenTermination() has no effect Reviewed-by: serb
author azvegint
date Tue, 23 Aug 2016 18:15:27 +0300
parents 7fb7ead73775
children 3c2bb0f0f129
files src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java src/java.desktop/macosx/classes/com/apple/eawt/_AppMiscHandlers.java
diffstat 2 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java	Tue Aug 23 14:47:53 2016 +0530
+++ b/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java	Tue Aug 23 18:15:27 2016 +0300
@@ -171,7 +171,8 @@
         currentQuitResponse = null;
 
         try {
-            if (defaultQuitAction == QuitStrategy.NORMAL_EXIT) System.exit(0);
+            if (defaultQuitAction == QuitStrategy.NORMAL_EXIT
+                    || _AppMiscHandlers.isSuddenTerminationEnbaled()) System.exit(0);
 
             if (defaultQuitAction != QuitStrategy.CLOSE_ALL_WINDOWS) {
                 throw new RuntimeException("Unknown quit action");
@@ -422,6 +423,10 @@
         }
 
         void performUsing(final QuitHandler handler, final _NativeEvent event) {
+            if (_AppMiscHandlers.isSuddenTerminationEnbaled()) {
+                performDefaultAction(event);
+                return;
+            }
             final MacQuitResponse response = obtainQuitResponse(); // obtains the "current" quit response
             handler.handleQuitRequestWith(new QuitEvent(), response);
         }
--- a/src/java.desktop/macosx/classes/com/apple/eawt/_AppMiscHandlers.java	Tue Aug 23 14:47:53 2016 +0530
+++ b/src/java.desktop/macosx/classes/com/apple/eawt/_AppMiscHandlers.java	Tue Aug 23 18:15:27 2016 +0300
@@ -26,6 +26,8 @@
 package com.apple.eawt;
 
 class _AppMiscHandlers {
+    private static boolean isSuddenTerminationEnabled;
+
     private static native void nativeOpenHelpViewer();
 
     private static native void nativeRequestActivation(final boolean allWindows);
@@ -47,10 +49,16 @@
     }
 
     static void enableSuddenTermination() {
+        isSuddenTerminationEnabled = true;
         nativeEnableSuddenTermination();
     }
 
     static void disableSuddenTermination() {
+        isSuddenTerminationEnabled = false;
         nativeDisableSuddenTermination();
     }
+
+    public static boolean isSuddenTerminationEnbaled() {
+        return isSuddenTerminationEnabled;
+    }
 }