Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix quitting on macOS #248

Merged
merged 1 commit into from
Oct 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public void actionPerformed(final ActionEvent e) {
}

// Used by OS X adaptations
public void quit() {
public boolean quit() {
actionPerformed(null);
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static void addOSXHandler(String handlerClassName,

Class<?> handlerClass = Class.forName(handlerClassName);
if (action != null) {
Object aboutHandlerProxy =
Object handlerProxy =
Proxy.newProxyInstance(OSXSupport.class.getClassLoader(),
new Class[]{handlerClass},
new InvocationHandler() {
Expand All @@ -121,10 +121,14 @@ public Object invoke(Object o, Method method, Object[] args) throws Throwable {
if (method.getName().equals(handlerMethodName)) {
action.actionPerformed(null);
}
if (method.getName().equals("handleQuitRequestWith")) {
Object quitResponse = args[1];
Class.forName("com.apple.eawt.QuitResponse").getDeclaredMethod("performQuit").invoke(quitResponse);
}
return null;
}
});
application.getClass().getMethod(handlerSetterMethodName, handlerClass).invoke(application, aboutHandlerProxy);
application.getClass().getMethod(handlerSetterMethodName, handlerClass).invoke(application, handlerProxy);
} else {
application.getClass().getMethod(handlerSetterMethodName, handlerClass).invoke(application, (Object) null);
}
Expand Down