8162840: Desktop. enableSuddenTermination() has no effect

Reviewed-by: serb
This commit is contained in:
Alexander Zvegintsev 2016-08-23 18:15:27 +03:00
parent 5a41e81056
commit 17cd11bc15
2 changed files with 14 additions and 1 deletions

View File

@ -171,7 +171,8 @@ class _AppEventHandler {
currentQuitResponse = null; currentQuitResponse = null;
try { 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) { if (defaultQuitAction != QuitStrategy.CLOSE_ALL_WINDOWS) {
throw new RuntimeException("Unknown quit action"); throw new RuntimeException("Unknown quit action");
@ -422,6 +423,10 @@ class _AppEventHandler {
} }
void performUsing(final QuitHandler handler, final _NativeEvent event) { void performUsing(final QuitHandler handler, final _NativeEvent event) {
if (_AppMiscHandlers.isSuddenTerminationEnbaled()) {
performDefaultAction(event);
return;
}
final MacQuitResponse response = obtainQuitResponse(); // obtains the "current" quit response final MacQuitResponse response = obtainQuitResponse(); // obtains the "current" quit response
handler.handleQuitRequestWith(new QuitEvent(), response); handler.handleQuitRequestWith(new QuitEvent(), response);
} }

View File

@ -26,6 +26,8 @@
package com.apple.eawt; package com.apple.eawt;
class _AppMiscHandlers { class _AppMiscHandlers {
private static boolean isSuddenTerminationEnabled;
private static native void nativeOpenHelpViewer(); private static native void nativeOpenHelpViewer();
private static native void nativeRequestActivation(final boolean allWindows); private static native void nativeRequestActivation(final boolean allWindows);
@ -47,10 +49,16 @@ class _AppMiscHandlers {
} }
static void enableSuddenTermination() { static void enableSuddenTermination() {
isSuddenTerminationEnabled = true;
nativeEnableSuddenTermination(); nativeEnableSuddenTermination();
} }
static void disableSuddenTermination() { static void disableSuddenTermination() {
isSuddenTerminationEnabled = false;
nativeDisableSuddenTermination(); nativeDisableSuddenTermination();
} }
public static boolean isSuddenTerminationEnbaled() {
return isSuddenTerminationEnabled;
}
} }