United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 7149085 [macosx] Quit with QuitStrategy CLOSE_ALL_WINDOWS does terminate application
7149085 : [macosx] Quit with QuitStrategy CLOSE_ALL_WINDOWS does terminate application

Details
Type:
Bug
Submit Date:
2012-02-27
Status:
Closed
Updated Date:
2012-04-04
Project Name:
JDK
Resolved Date:
2012-04-04
Component:
client-libs
OS:
os_x
Sub-Component:
java.awt
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:
7u4

Related Reports
Backport:
Duplicate:

Sub Tasks

Description
Mac OS X 10.7.3 macmini4,1
Run the attached application. Here, QuitStrategy.CLOSE_ALL_WINDOWS is set. Mac OS sends to all windows in back-to-front order a closing event. On Java level, it is windowClosing(), and if on windowClosing nothing is explicitly closed, it is equivalent to no action. So it works on Apple Java 6: you will see printout from windowClosing() listener's method, and that's it.

However in jdk7 the application frames receive windowClosing, do not receive windowClosed, and application terminates.

                                    

Comments
EVALUATION

Now in b18 we behave just like Apple Java 6 in u31.

(And unlike Apple Java 6 u24/26 which did as we did in b17).
                                     
2012-04-04
EVALUATION

We should never return YES from applicationShouldTerminate:. Either we call System.exit() ourselves, or the app will call it when processing WINDOW_CLOSING events.
                                     
2012-03-20
SUGGESTED FIX

--- old/src/macosx/classes/com/apple/eawt/_AppEventHandler.java	2012-03-20 18:28:42.000000000 +0400
+++ new/src/macosx/classes/com/apple/eawt/_AppEventHandler.java	2012-03-20 18:28:41.000000000 +0400
@@ -157,7 +157,10 @@
                 }
             });
         } finally {
-            nativeReplyToAppShouldTerminate(true);
+            // Either we've just called System.exit(), or the app will call
+            // it when processing a WINDOW_CLOSING event. Either way, we reply
+            // to Cocoa that we don't want to exit the event loop yet.
+            nativeReplyToAppShouldTerminate(false);
         }
     }
                                     
2012-03-20



Hardware and Software, Engineered to Work Together