Skip to content

Commit

Permalink
Fix the crash described in #5132. Patches were submitting UndoMemento…
Browse files Browse the repository at this point in the history
…s to the undo system even though they ended up not being added to the scene.

The new approach is to only add them to the scene after it's clear they are going to be kept.
  • Loading branch information
codereader committed Mar 23, 2020
1 parent 6ffd7e3 commit e1c31bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
3 changes: 0 additions & 3 deletions radiant/patch/Patch.cpp
Expand Up @@ -2539,9 +2539,6 @@ void Patch::createThickenedWall(const Patch& sourcePatch,

// Notify the patch about the change
controlPointsChanged();

// Texture the patch "naturally"
NaturalTexture();
}

void Patch::stitchTextureFrom(Patch& sourcePatch) {
Expand Down
14 changes: 7 additions & 7 deletions radiant/patch/algorithm/General.cpp
Expand Up @@ -53,10 +53,6 @@ void thicken(const PatchNodePtr& sourcePatch, float thickness, bool createSeams,
// Now create the four walls
for (int i = 0; i < 4; i++)
{
// Insert each node into the same parent as the existing patch
// It's vital to do this first, otherwise these patches won't have valid shaders
parent->addChildNode(nodes[i]);

// Retrieve the contained patch from the node
Patch* wallPatch = Node_getPatch(nodes[i]);

Expand All @@ -65,15 +61,19 @@ void thicken(const PatchNodePtr& sourcePatch, float thickness, bool createSeams,

if (!wallPatch->isDegenerate())
{
// Insert each node into the same parent as the existing patch
// It's vital to do this first, otherwise these patches won't have valid shaders
parent->addChildNode(nodes[i]);

// Now the shader is realised, apply natural scale
wallPatch->NaturalTexture();

// Now select the newly created patch
Node_setSelected(nodes[i], true);
}
else
{
rMessage() << "Thicken: Discarding degenerate patch." << std::endl;

// Remove again
parent->removeChildNode(nodes[i]);
}
}
}
Expand Down

0 comments on commit e1c31bb

Please sign in to comment.