diff --git a/src/main/java/com/tagtraum/perf/gcviewer/ctrl/action/Exit.java b/src/main/java/com/tagtraum/perf/gcviewer/ctrl/action/Exit.java index 26a949d7..5e2474fe 100644 --- a/src/main/java/com/tagtraum/perf/gcviewer/ctrl/action/Exit.java +++ b/src/main/java/com/tagtraum/perf/gcviewer/ctrl/action/Exit.java @@ -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; } } diff --git a/src/main/java/com/tagtraum/perf/gcviewer/view/util/OSXSupport.java b/src/main/java/com/tagtraum/perf/gcviewer/view/util/OSXSupport.java index e6df4e51..ad5cb830 100644 --- a/src/main/java/com/tagtraum/perf/gcviewer/view/util/OSXSupport.java +++ b/src/main/java/com/tagtraum/perf/gcviewer/view/util/OSXSupport.java @@ -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() { @@ -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); }