diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index f2a0dae48a..4ec9e6029f 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -378,42 +378,9 @@ Application::Application(bool GUIenabled) std::bind(&Gui::Application::slotRelabelDocument, this, sp::_1)); App::GetApplication().signalShowHidden.connect( std::bind(&Gui::Application::slotShowHidden, this, sp::_1)); + App::GetApplication().signalFinishRestoreDocument.connect( + std::bind(&Gui::Application::slotFinishRestoreDocument, this, sp::_1)); // NOLINTEND - App::GetApplication().signalFinishOpenDocument.connect([]() { - std::vector docs; - for(auto doc : App::GetApplication().getDocuments()) { - if(doc->testStatus(App::Document::RecomputeOnRestore)) { - docs.push_back(doc); - doc->setStatus(App::Document::RecomputeOnRestore, false); - } - } - if(docs.empty() || !App::DocumentParams::getWarnRecomputeOnRestore()) - return; - WaitCursor wc; - wc.restoreCursor(); - auto res = QMessageBox::warning(getMainWindow(), QObject::tr("Recompution required"), - QObject::tr("Some document(s) require recomputation for migration purpose. " - "It is highly recommended to perform a recomputation before " - "any modification to avoid compatibility problem.\n\n" - "Do you want to recompute now?"), - QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes); - if(res != QMessageBox::Yes) - return; - bool hasError = false; - for(auto doc : App::Document::getDependentDocuments(docs,true)) { - try { - doc->recompute({},false,&hasError); - } catch (Base::Exception &e) { - e.ReportException(); - hasError = true; - } - } - if(hasError) - QMessageBox::critical(getMainWindow(), QObject::tr("Recompute error"), - QObject::tr("Failed to recompute some document(s).\n" - "Please check report view for more details.")); - }); - // install the last active language ParameterGrp::handle hPGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp"); hPGrp = hPGrp->GetGroup("Preferences")->GetGroup("General"); @@ -1012,6 +979,42 @@ void Application::slotShowHidden(const App::Document& Doc) signalShowHidden(*doc->second); } +void Application::slotFinishRestoreDocument(const App::Document& Doc) { + Doc; + std::vector docs; + for (auto doc: App::GetApplication().getDocuments()) { + if (doc->testStatus(App::Document::RecomputeOnRestore)) { + docs.push_back(doc); + doc->setStatus(App::Document::RecomputeOnRestore, false); + } + } + if (docs.empty()) + return; + WaitCursor wc; + wc.restoreCursor(); + auto res = QMessageBox::warning(getMainWindow(), QObject::tr("Recompution required"), + QObject::tr("Some document(s) require recomputation for migration purpose. " + "It is highly recommended to perform a recomputation before " + "any modification to avoid compatibility problem.\n\n" + "Do you want to recompute now?"), + QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); + if (res != QMessageBox::Yes) + return; + bool hasError = false; + for (auto doc: App::Document::getDependentDocuments(docs, true)) { + try { + doc->recompute({}, false, &hasError); + } catch (Base::Exception &e) { + e.ReportException(); + hasError = true; + } + } + if (hasError) + QMessageBox::critical(getMainWindow(), QObject::tr("Recompute error"), + QObject::tr("Failed to recompute some document(s).\n" + "Please check report view for more details.")); +} + void Application::slotActiveDocument(const App::Document& Doc) { std::map::iterator doc = d->documents.find(&Doc); diff --git a/src/Gui/Application.h b/src/Gui/Application.h index bbb1aa2258..5a87d3c100 100644 --- a/src/Gui/Application.h +++ b/src/Gui/Application.h @@ -131,6 +131,8 @@ public: boost::signals2::signal signalRefreshWorkbenches; /// signal on show hidden items boost::signals2::signal signalShowHidden; + /// signal on document open complete + boost::signals2::signal signalFinishRestoreDocument; /// signal on activating view boost::signals2::signal signalActivateView; /// signal on entering in edit mode @@ -151,6 +153,7 @@ protected: void slotRenameDocument(const App::Document&); void slotActiveDocument(const App::Document&); void slotShowHidden(const App::Document&); + void slotFinishRestoreDocument(const App::Document&); void slotNewObject(const ViewProvider&); void slotDeletedObject(const ViewProvider&); void slotChangedObject(const ViewProvider&, const App::Property& Prop); diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index bd3e7a8518..045573a337 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -117,6 +117,7 @@ struct DocumentP Connection connectStartLoadDocument; Connection connectFinishLoadDocument; Connection connectShowHidden; + Connection connectFinishRestoreDocument; Connection connectFinishRestoreObject; Connection connectExportObjects; Connection connectImportObjects; @@ -184,7 +185,6 @@ Document::Document(App::Document* pcDocument,Application * app) (std::bind(&Gui::Document::slotFinishRestoreDocument, this, sp::_1)); d->connectShowHidden = App::GetApplication().signalShowHidden.connect (std::bind(&Gui::Document::slotShowHidden, this, sp::_1)); - d->connectChangePropertyEditor = pcDocument->signalChangePropertyEditor.connect (std::bind(&Gui::Document::slotChangePropertyEditor, this, sp::_1, sp::_2)); d->connectChangeDocument = d->_pcDocument->signalChanged.connect // use the same slot function diff --git a/src/Mod/Part/App/PropertyTopoShape.cpp b/src/Mod/Part/App/PropertyTopoShape.cpp index b392c75577..060de241b9 100644 --- a/src/Mod/Part/App/PropertyTopoShape.cpp +++ b/src/Mod/Part/App/PropertyTopoShape.cpp @@ -389,11 +389,12 @@ void PropertyPartShape::Restore(Base::XMLReader &reader) } } } else if(owner && !owner->getDocument()->testStatus(App::Document::PartialDoc)) { + // Toponaming 09/2024: Original code has a whole infrastructure of document parameters we aren't bring in: // if(App::DocumentParams::getWarnRecomputeOnRestore()) { - if( true ) { - FC_WARN("Pending recompute for generating element map: " << owner->getFullName()); - owner->getDocument()->addRecomputeObject(owner); - } + // However, this warning appears on all files without element maps, and is now superceded by a user dialog + // after loading that is triggered by any addRecomputeObject() + // FC_WARN("Pending recompute for generating element map: " << owner->getFullName()); + owner->getDocument()->addRecomputeObject(owner); } if (!shape.isNull() || !_Shape.isNull()) {