| 823 | } |
| 824 | |
| 825 | bool DocumentController::saveSomeDocuments(const QList<IDocument*>& list, SaveSelectionMode mode) |
| 826 | { |
| 827 | if (mode == SaveSelectionMode::DontAskUser) { |
| 828 | bool ret = true; |
| 829 | const auto documents = modifiedDocuments(list); |
| 830 | const QPointer thisGuard(this); |
| 831 | for (IDocument* doc : documents) { |
| 832 | if (!DocumentController::isEmptyDocumentUrl(doc->url()) && !doc->save()) { |
| 833 | if (!thisGuard) { |
| 834 | return false; // already destroyed (KDevelop is probably exiting now) |
| 835 | } |
| 836 | // Fail because the user canceled saving a document. |
| 837 | // Keep saving the remaining documents, because they are likely to be |
| 838 | // saved without user prompts. And our caller may not be able to |
| 839 | // (or choose not to) abort the operation that triggered the saving. |
| 840 | ret = false; |
| 841 | } |
| 842 | } |
| 843 | return ret; |
| 844 | } else { |
| 845 | // Ask the user which documents to save |
| 846 | QList<IDocument*> checkSave = modifiedDocuments(list); |
| 847 | |
| 848 | if (!checkSave.isEmpty()) { |
| 849 | ScopedDialog<KSaveSelectDialog> dialog(checkSave, qApp->activeWindow()); |
| 850 | return dialog->exec(); |
| 851 | } |
| 852 | return true; |
| 853 | } |
| 854 | } |
| 855 | |
| 856 | QList< IDocument * > KDevelop::DocumentController::visibleDocumentsInWindow(MainWindow * mw) const |
| 857 | { |