You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2020/03/28 12:53:37 UTC

[groovy] 01/06: Fix 'Save changes?' dialog quitting on cancel with Java 11 on OSX

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 318fbe6440e2e3d7af861c033798eaf5431a3f47
Author: timyates <ti...@gmail.com>
AuthorDate: Fri Mar 27 19:07:39 2020 +0000

    Fix 'Save changes?' dialog quitting on cancel with Java 11 on OSX
    
    If the user quits the Groovy console with unsaved changes, it asks if
    they want to 'Save changes?'
    
    Under Java 11, this still quits if they click 'Cancel'
    
    Looks like we need to cancel the quit event if cancel was pressed
    
    (cherry picked from commit e9804c4acafff379d738a28c0a7ff05110a13406)
---
 .../src/main/groovy/groovy/console/ui/Console.groovy        | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy b/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy
index dc8cf38..24d74be 100644
--- a/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy
+++ b/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy
@@ -780,13 +780,17 @@ class Console implements CaretListener, HyperlinkListener, ComponentListener, Fo
     }
 
     void exitDesktop(EventObject evt = null, quitResponse = null) {
-        exit(evt)
-        quitResponse.performQuit()
+        if (exit(evt)) {
+            quitResponse.performQuit()
+        } else {
+            quitResponse.cancelQuit()
+        }
     }
 
-    void exit(EventObject evt = null) {
+    boolean exit(EventObject evt = null) {
         if (askToInterruptScript()) {
-            if (askToSaveFile()) {
+            def exit = askToSaveFile()
+            if (exit) {
                 if (frame instanceof Window) {
                     frame.hide()
                     frame.dispose()
@@ -799,6 +803,7 @@ class Console implements CaretListener, HyperlinkListener, ComponentListener, Fo
                     systemErrorInterceptor.stop()
                 }
             }
+            return exit
         }
     }