@@ -637,7 +637,7 @@ define(function (require, exports, module) {
637
637
* Common implementation for close/quit/reload which all mostly
638
638
* the same except for the final step
639
639
*/
640
- function _handleWindowGoingAway ( commandData , postCloseHandler ) {
640
+ function _handleWindowGoingAway ( commandData , postCloseHandler , failHandler ) {
641
641
if ( _windowGoingAway ) {
642
642
//if we get called back while we're closing, then just return
643
643
return ( new $ . Deferred ( ) ) . resolve ( ) . promise ( ) ;
@@ -653,22 +653,46 @@ define(function (require, exports, module) {
653
653
_windowGoingAway = true ;
654
654
PreferencesManager . savePreferences ( ) ;
655
655
postCloseHandler ( ) ;
656
+ } )
657
+ . fail ( function ( ) {
658
+ if ( failHandler ) {
659
+ failHandler ( ) ;
660
+ }
656
661
} ) ;
657
662
}
658
663
659
664
/** Confirms any unsaved changes, then closes the window */
660
665
function handleFileCloseWindow ( commandData ) {
661
- return _handleWindowGoingAway ( commandData , function ( ) {
662
- window . close ( ) ;
663
- } ) ;
666
+ return _handleWindowGoingAway (
667
+ commandData ,
668
+ function ( ) {
669
+ window . close ( ) ;
670
+ } ,
671
+ function ( ) {
672
+ // if fail, tell the app to abort any pending quit operation.
673
+ // TODO: remove this if statement when we move to the new CEF3 shell
674
+ if ( brackets . app . abortQuit ) {
675
+ brackets . app . abortQuit ( ) ;
676
+ }
677
+ }
678
+ ) ;
664
679
}
665
680
666
681
/** Closes the window, then quits the app */
667
682
function handleFileQuit ( commandData ) {
668
- return _handleWindowGoingAway ( commandData , function ( ) {
669
- brackets . app . quit ( ) ;
670
- } ) ;
671
- // if fail, don't exit: user canceled (or asked us to save changes first, but we failed to do so)
683
+ return _handleWindowGoingAway (
684
+ commandData ,
685
+ function ( ) {
686
+ brackets . app . quit ( ) ;
687
+ } ,
688
+ function ( ) {
689
+ // if fail, don't exit: user canceled (or asked us to save changes first, but we failed to do so)
690
+ // TODO: remove this if statement when we move to the new CEF3 shell
691
+ if ( brackets . app . abortQuit ) {
692
+ brackets . app . abortQuit ( ) ;
693
+ }
694
+ }
695
+ ) ;
672
696
}
673
697
674
698
/** Does a full reload of the browser window */
0 commit comments