Move code for recompute dialog and disable warning

This commit is contained in:
bgbsww
2024-09-14 13:31:06 -04:00
committed by Yorik van Havre
parent c4d5cc5967
commit 4a04a7eb91
4 changed files with 47 additions and 40 deletions

View File

@@ -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<App::Document*> 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<App::Document *> 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<const App::Document*, Gui::Document*>::iterator doc = d->documents.find(&Doc);

View File

@@ -131,6 +131,8 @@ public:
boost::signals2::signal<void ()> signalRefreshWorkbenches;
/// signal on show hidden items
boost::signals2::signal<void (const Gui::Document&)> signalShowHidden;
/// signal on document open complete
boost::signals2::signal<void (const Gui::Document&)> signalFinishRestoreDocument;
/// signal on activating view
boost::signals2::signal<void (const Gui::MDIView*)> 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);

View File

@@ -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

View File

@@ -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()) {