/////////////////////////////////////////////////////////////////////////////// // Closes the specified file. Determines if the file needs to be saved, and // handles any other revision control interactions. Notifies any interested // listeners if the file is successfully closed. If prompt is set to true, // the user will be prompted to save their file before it is closed. // // Fires an event to notify listeners that this document is now closed. Any // objects that are holding pointers to this document should release them. // bool DocumentManager::CloseDocument( DocumentPtr document, bool prompt ) { HELIUM_ASSERT( document.ReferencesObject() ); bool shouldClose = !prompt; bool wasClosed = false; if ( prompt ) { std::string unused; switch ( QueryClose( document ) ) { case SaveActions::Save: shouldClose = SaveDocument( document, unused ); break; case SaveActions::Skip: shouldClose = true; break; case SaveActions::Abort: shouldClose = false; break; case SaveActions::SaveAll: case SaveActions::SkipAll: break; } } if ( shouldClose ) { // This will raise the e_Closed event when the document is finished closing and // callback to OnDocumentClosed, which will remove the document from m_Documents document->Close(); wasClosed = true; } return wasClosed; }