8162840: Desktop. enableSuddenTermination() has no effect
authorazvegint
Tue, 23 Aug 2016 18:15:27 +0300
changeset 40717 02500a642a8e
parent 40716 5f30f35b9ad4
child 40718 fe2adbe4d101
8162840: Desktop. enableSuddenTermination() has no effect Reviewed-by: serb
jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java
jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMiscHandlers.java
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java	Tue Aug 23 14:47:53 2016 +0530
+++ b/jdk/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/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMiscHandlers.java	Tue Aug 23 14:47:53 2016 +0530
+++ b/jdk/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;
+    }
 }