diff --git a/editor/base/nsEditorShell.cpp b/editor/base/nsEditorShell.cpp index 8c83e431f37d..414fc7b0d95e 100644 --- a/editor/base/nsEditorShell.cpp +++ b/editor/base/nsEditorShell.cpp @@ -1427,15 +1427,15 @@ nsEditorShell::SaveAs() } NS_IMETHODIMP -nsEditorShell::CloseWindow() +nsEditorShell::CloseWindow( PRBool *_retval ) { nsresult rv = NS_OK; - PRBool result; - rv = CheckAndSaveDocument(GetString("BeforeClosing").GetUnicode(),&result); + rv = CheckAndSaveDocument(GetString("BeforeClosing").GetUnicode(),_retval); + // Don't close the window if there was an error saving file or // user canceled an action along the way - if (NS_SUCCEEDED(rv) && result) + if (NS_SUCCEEDED(rv) && *_retval) mWebShellWin->Close(); return rv; diff --git a/editor/composer/src/nsEditorShell.cpp b/editor/composer/src/nsEditorShell.cpp index 8c83e431f37d..414fc7b0d95e 100644 --- a/editor/composer/src/nsEditorShell.cpp +++ b/editor/composer/src/nsEditorShell.cpp @@ -1427,15 +1427,15 @@ nsEditorShell::SaveAs() } NS_IMETHODIMP -nsEditorShell::CloseWindow() +nsEditorShell::CloseWindow( PRBool *_retval ) { nsresult rv = NS_OK; - PRBool result; - rv = CheckAndSaveDocument(GetString("BeforeClosing").GetUnicode(),&result); + rv = CheckAndSaveDocument(GetString("BeforeClosing").GetUnicode(),_retval); + // Don't close the window if there was an error saving file or // user canceled an action along the way - if (NS_SUCCEEDED(rv) && result) + if (NS_SUCCEEDED(rv) && *_retval) mWebShellWin->Close(); return rv; diff --git a/editor/idl/nsIEditorShell.idl b/editor/idl/nsIEditorShell.idl index 43dbd0abd1a8..f6defd5ac449 100644 --- a/editor/idl/nsIEditorShell.idl +++ b/editor/idl/nsIEditorShell.idl @@ -120,7 +120,7 @@ interface nsIEditorShell : nsISupports */ boolean CheckAndSaveDocument(in wstring reasonToSave); - void CloseWindow(); + boolean CloseWindow(); void Print(); void Exit(); diff --git a/editor/ui/composer/content/EditorCommands.js b/editor/ui/composer/content/EditorCommands.js index 5df517662717..be855a3ad303 100644 --- a/editor/ui/composer/content/EditorCommands.js +++ b/editor/ui/composer/content/EditorCommands.js @@ -47,6 +47,7 @@ function EditorOnLoad() { } // Continue with normal startup. EditorStartup( 'html', document.getElementById("content-frame")); + window.tryToClose = EditorClose; return; } @@ -251,7 +252,7 @@ function EditorPrint() function EditorClose() { dump("In EditorClose...\n"); - editorShell.CloseWindow(); + return editorShell.CloseWindow(); // This doesn't work, but we can close // the window in the EditorAppShell, so we don't need it //window.close(); @@ -1251,7 +1252,8 @@ function EditorUnitTests() function EditorExit() { dump("Exiting\n"); - editorShell.Exit(); + // editorShell.Exit(); + goQuitApplication(); } function EditorTestDocument()