Skip to content

Commit

Permalink
Bug fix: avoid crash when opening flip config window / operating flip…
Browse files Browse the repository at this point in the history
… related operation. (#296)

* Fix bug: Avoid crash if trying to remove vertex when mirrored by axes, and no correspoinding vertex exists.

* Bug fix: fix for (#291), and additonal undo action for mask addition/removal.

* Bug fix: avoid crash when pair.parts[0] and pair.parts[1] is removed.

* fix wrong guard logic.
  • Loading branch information
seagetch authored Jul 5, 2023
1 parent 1edc183 commit 4fabc60
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions source/creator/windows/flipconfig.d
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ void incLoadFlipConfig(Puppet puppet) {
foreach (pair; flipPairs) {
pair.finalize(puppet);
}
// Removing unused pair, and ensure that pair.parts[0] exists.
flipPairs.remove!(p=> p.parts[0] is null && p.parts[1] is null);
foreach (i, pair; flipPairs) {
if (pair.parts[0] is null) {
pair.parts[0] = pair.parts[1];
pair.parts[1] = null;
}
}
}
}

Expand Down Expand Up @@ -248,6 +256,15 @@ private:
int deleted = -1;

foreach(i, ref FlipPair pair; pairs) {
// Avoid crash when pair information is corrupted.
// This should be checked on window open, and model loading.
// This logic is a guard logic for potential errors.
if (pair.parts[0] is null && pair.parts[1] is null) {
continue;
} else if (pair.parts[0] is null) {
pair.parts[0] = pair.parts[1];
pair.parts[1] = null;
}

igPushID(cast(int)i);

Expand Down Expand Up @@ -498,6 +515,8 @@ public:
auto puppet = incActivePuppet();
nodes = puppet.findNodesType!Node(puppet.root);
pairs = incGetFlipPairs().dup;
// Removing unused pairs (happens when target nodes are removed.)
pairs.remove!(p=> p.parts[0] is null && p.parts[1] is null);
foreach (i, pair; pairs) {
if (pair.parts[0] !is null)
map[pair.parts[0].uuid] = i;
Expand Down

0 comments on commit 4fabc60

Please sign in to comment.