Skip to content

Commit 6157084

Browse files
committed
Fix #131. Prevent UI freeze by having a timeout when finding which constraints can be removed to fix jacobian.
1 parent e74185b commit 6157084

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

src/sketch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ class Group {
189189
struct {
190190
SolveResult how;
191191
int dof;
192+
bool timeout;
192193
List<hConstraint> remove;
193194
} solved;
194195

src/system.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,17 @@ void System::WriteEquationsExceptFor(hConstraint hc, Group *g) {
355355
}
356356

357357
void System::FindWhichToRemoveToFixJacobian(Group *g, List<hConstraint> *bad, bool forceDofCheck) {
358+
auto time = GetMilliseconds();
359+
g->solved.timeout = false;
358360
int a;
359361

360362
for(a = 0; a < 2; a++) {
361363
for(auto &con : SK.constraint) {
364+
if((GetMilliseconds() - time) > 1500) { // todo: make timeout configurable
365+
g->solved.timeout = true;
366+
return;
367+
}
368+
362369
ConstraintBase *c = &con;
363370
if(c->group != g->h) continue;
364371
if((c->type == Constraint::Type::POINTS_COINCIDENT && a == 0) ||

src/textscreens.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,11 @@ void TextWindow::ShowGroupSolveInfo() {
578578
c->DescriptionString().c_str());
579579
}
580580

581+
if(g->solved.timeout) {
582+
Printf(true, "%FxSome items in list have been ommitted%Fd");
583+
Printf(false, "%Fxbecause the operation timed out.%Fd");
584+
}
585+
581586
Printf(true, "It may be possible to fix the problem ");
582587
Printf(false, "by selecting Edit -> Undo.");
583588

0 commit comments

Comments
 (0)