App: make recompute aborting optional
This commit is contained in:
@@ -3068,9 +3068,7 @@ int Document::recompute(const std::vector<App::DocumentObject*> &objs, bool forc
|
||||
// delete recompute log
|
||||
d->clearRecomputeLog();
|
||||
|
||||
//do we have anything to do?
|
||||
if(d->objectMap.empty())
|
||||
return 0;
|
||||
FC_TIME_INIT(t);
|
||||
|
||||
Base::ObjectStatusLocker<Document::Status, Document> exe(Document::Recomputing, this);
|
||||
signalBeforeRecompute(*this);
|
||||
@@ -3099,14 +3097,23 @@ int Document::recompute(const std::vector<App::DocumentObject*> &objs, bool forc
|
||||
for(auto obj : topoSortedObjects)
|
||||
obj->setStatus(ObjectStatus::PendingRecompute,true);
|
||||
|
||||
ParameterGrp::handle hGrp = GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Document");
|
||||
bool canAbort = hGrp->GetBool("CanAbortRecompute",true);
|
||||
|
||||
std::set<App::DocumentObject *> filter;
|
||||
size_t idx = 0;
|
||||
|
||||
FC_TIME_INIT(t2);
|
||||
|
||||
try {
|
||||
// maximum two passes to allow some form of dependency inversion
|
||||
for(int passes=0; passes<2 && idx<topoSortedObjects.size(); ++passes) {
|
||||
Base::SequencerLauncher seq("Recompute...", topoSortedObjects.size());
|
||||
std::unique_ptr<Base::SequencerLauncher> seq;
|
||||
if(canAbort)
|
||||
seq.reset(new Base::SequencerLauncher("Recompute...", topoSortedObjects.size()));
|
||||
FC_LOG("Recompute pass " << passes);
|
||||
for (;idx<topoSortedObjects.size();seq.next(true),++idx) {
|
||||
for (;idx<topoSortedObjects.size();(seq?seq->next(true):true),++idx) {
|
||||
auto obj = topoSortedObjects[idx];
|
||||
if(!obj->getNameInDocument() || filter.find(obj)!=filter.end())
|
||||
continue;
|
||||
@@ -3160,6 +3167,8 @@ int Document::recompute(const std::vector<App::DocumentObject*> &objs, bool forc
|
||||
e.ReportException();
|
||||
}
|
||||
|
||||
FC_TIME_LOG(t2, "Recompute");
|
||||
|
||||
for(auto obj : topoSortedObjects) {
|
||||
if(!obj->getNameInDocument())
|
||||
continue;
|
||||
@@ -3171,6 +3180,11 @@ int Document::recompute(const std::vector<App::DocumentObject*> &objs, bool forc
|
||||
|
||||
signalRecomputed(*this,topoSortedObjects);
|
||||
|
||||
FC_TIME_LOG(t,"Recompute total");
|
||||
|
||||
if(d->_RecomputeLog.size())
|
||||
Base::Console().Error("Recompute failed! Please check report view.\n");
|
||||
|
||||
return objectCount;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>500</width>
|
||||
<height>685</height>
|
||||
<width>607</width>
|
||||
<height>720</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -170,6 +170,30 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="prefCanAbortRecompute">
|
||||
<property name="toolTip">
|
||||
<string>Allow user aborting document recomputation by pressing ESC.
|
||||
This feature may slightly increase recomputation time.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Allow aborting recomputation</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<string>CanAbortRecompute</string>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<string>Document</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -67,7 +67,7 @@ void DlgSettingsDocumentImp::saveSettings()
|
||||
prefUndoRedo->onSave();
|
||||
prefUndoRedoSize->onSave();
|
||||
prefSaveTransaction->onSave();
|
||||
prefDiscardTransaction->onSave();
|
||||
prefDiscardTransaction->onSave();
|
||||
prefSaveThumbnail->onSave();
|
||||
prefAddLogo->onSave();
|
||||
prefSaveBackupFiles->onSave();
|
||||
@@ -82,6 +82,7 @@ void DlgSettingsDocumentImp::saveSettings()
|
||||
prefRecovery->onSave();
|
||||
prefAutoSaveEnabled->onSave();
|
||||
prefAutoSaveTimeout->onSave();
|
||||
prefCanAbortRecompute->onSave();
|
||||
|
||||
int timeout = prefAutoSaveTimeout->value();
|
||||
if (!prefAutoSaveEnabled->isChecked())
|
||||
@@ -97,7 +98,7 @@ void DlgSettingsDocumentImp::loadSettings()
|
||||
prefUndoRedo->onRestore();
|
||||
prefUndoRedoSize->onRestore();
|
||||
prefSaveTransaction->onRestore();
|
||||
prefDiscardTransaction->onRestore();
|
||||
prefDiscardTransaction->onRestore();
|
||||
prefSaveThumbnail->onRestore();
|
||||
prefAddLogo->onRestore();
|
||||
prefSaveBackupFiles->onRestore();
|
||||
@@ -112,6 +113,7 @@ void DlgSettingsDocumentImp::loadSettings()
|
||||
prefRecovery->onRestore();
|
||||
prefAutoSaveEnabled->onRestore();
|
||||
prefAutoSaveTimeout->onRestore();
|
||||
prefCanAbortRecompute->onRestore();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,7 +123,7 @@ void DlgSettingsDocumentImp::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
retranslateUi(this);
|
||||
}
|
||||
}
|
||||
else {
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user