| 973 | } |
| 974 | |
| 975 | std::vector<Document*> Application::openDocuments(const std::vector<std::string> &filenames, |
| 976 | const std::vector<std::string> *paths, |
| 977 | const std::vector<std::string> *labels, |
| 978 | std::vector<std::string> *errs, |
| 979 | DocumentInitFlags initFlags) |
| 980 | { |
| 981 | std::vector<Document*> res(filenames.size(), nullptr); |
| 982 | if (filenames.empty()) |
| 983 | return res; |
| 984 | |
| 985 | if (errs) |
| 986 | errs->resize(filenames.size()); |
| 987 | |
| 988 | DocOpenGuard guard(_isRestoring, signalFinishOpenDocument); |
| 989 | _pendingDocs.clear(); |
| 990 | _pendingDocsReopen.clear(); |
| 991 | _pendingDocMap.clear(); |
| 992 | _docReloadAttempts.clear(); |
| 993 | |
| 994 | signalStartOpenDocument(); |
| 995 | |
| 996 | ParameterGrp::handle hGrp = GetParameterGroupByPath("User parameter:BaseApp/Preferences/Document"); |
| 997 | _allowPartial = !hGrp->GetBool("NoPartialLoading",false); |
| 998 | |
| 999 | for (auto &name : filenames) |
| 1000 | _pendingDocs.emplace_back(name.c_str()); |
| 1001 | |
| 1002 | std::map<DocumentT, DocTiming> timings; |
| 1003 | |
| 1004 | Base::TimeTracker tracker("Application::openDocuments"); |
| 1005 | |
| 1006 | std::vector<DocumentT> openedDocs; |
| 1007 | |
| 1008 | int pass = 0; |
| 1009 | do { |
| 1010 | std::set<DocumentT> newDocs; |
| 1011 | for (std::size_t count=0;; ++count) { |
| 1012 | std::string name = std::move(_pendingDocs.front()); |
| 1013 | _pendingDocs.pop_front(); |
| 1014 | bool isMainDoc = (pass == 0 && count < filenames.size()); |
| 1015 | |
| 1016 | try { |
| 1017 | _objCount = -1; |
| 1018 | std::vector<std::string> objNames; |
| 1019 | if (_allowPartial) { |
| 1020 | auto it = _pendingDocMap.find(name); |
| 1021 | if (it != _pendingDocMap.end()) { |
| 1022 | if(isMainDoc) |
| 1023 | it->second.clear(); |
| 1024 | else |
| 1025 | objNames.swap(it->second); |
| 1026 | _pendingDocMap.erase(it); |
| 1027 | } |
| 1028 | } |
| 1029 | |
| 1030 | DocTiming timing; |
| 1031 | std::chrono::high_resolution_clock::time_point startTime = std::chrono::high_resolution_clock::now(); |
| 1032 | |