FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

generate: fix `PruneRequests()` to actually prune requests · solvespace/solvespace@9fe43d5 · GitHub

Commit 9fe43d5

Browse files
committed
generate: fix PruneRequests() to actually prune requests
Commit 86f20cc (merged in #428) was marked NFC, even though it didn't just convert loops to ranged-for, but also introduced a functional change in the request pruning logic to prune entities instead. This doesn't make much sense, since the requests will stay, and their entities will simply be regenerated, leading to an infinite recursion and resulting in a crash with stack overflow. I'm not sure how it slipped past code review, but this was the cause of #628 and is the reason for the additional workplane deletion code that whitequark added in 586b047, so this commit also reverts that code as well.
1 parent 8042810 commit 9fe43d5

2 files changed

Lines changed: 20 additions & 15 deletions

File tree

‎src/generate.cpp‎

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,27 @@ bool SolveSpaceUI::PruneGroups(hGroup hg) {
8787
}
8888

8989
bool SolveSpaceUI::PruneRequests(hGroup hg) {
90-
auto e = std::find_if(SK.entity.begin(), SK.entity.end(),
91-
[&](Entity &e) { return e.group == hg && !EntityExists(e.workplane); });
92-
if(e != SK.entity.end()) {
93-
(deleted.requests)++;
94-
SK.entity.RemoveById(e->h);
95-
return true;
90+
const int requests = SK.request.n;
91+
for(Entity &e : SK.entity) {
92+
if(e.group != hg) {
93+
continue;
94+
}
95+
96+
if(!e.h.isFromRequest()) {
97+
continue;
98+
}
99+
100+
if(EntityExists(e.workplane)) {
101+
continue;
102+
}
103+
104+
Request *r = SK.GetRequest(e.h.request());
105+
r->tag = 1;
96106
}
97-
return false;
107+
SK.request.RemoveTagged();
108+
deleted.requests += requests - SK.request.n;
109+
110+
return requests > SK.request.n;
98111
}
99112

100113
bool SolveSpaceUI::PruneConstraints(hGroup hg) {

‎src/graphicswin.cpp‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,14 +1039,6 @@ void GraphicsWindow::ForceTextWindowShown() {
10391039
}
10401040

10411041
void GraphicsWindow::DeleteTaggedRequests() {
1042-
// Delete any requests that were affected by this deletion.
1043-
for(Request &r : SK.request) {
1044-
if(r.workplane == Entity::FREE_IN_3D) continue;
1045-
if(!r.workplane.isFromRequest()) continue;
1046-
Request *wrkpl = SK.GetRequest(r.workplane.request());
1047-
if(wrkpl->tag)
1048-
r.tag = 1;
1049-
}
10501042
// Rewrite any point-coincident constraints that were affected by this
10511043
// deletion.
10521044
for(Request &r : SK.request) {

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL