Skip to content

Commit

Permalink
#5347: Harden the BrushCreatorTool against deletions of the drag-crea…
Browse files Browse the repository at this point in the history
…ted brush in the middle of the operation.
  • Loading branch information
codereader committed Oct 1, 2020
1 parent d162f4a commit 9c6ac11
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions radiant/xyview/tools/BrushCreatorTool.cpp
Expand Up @@ -103,10 +103,18 @@ MouseTool::Result BrushCreatorTool::onMouseMove(Event& ev)
auto worldspawn = GlobalMapModule().findOrInsertWorldspawn();
scene::addNodeToContainer(_brush, worldspawn);
}

// Make sure the brush is selected
Node_setSelected(_brush, true);
}

// Make sure the brush is selected
Node_setSelected(_brush, true);
// It's possible that the brush we created has been deleted in the meantime
// check the brush object for validity
if (!_brush->getParent() || GlobalSelectionSystem().countSelected() == 0)
{
_brush.reset();
return Result::Finished;
}

// Dispatch the command
GlobalCommandSystem().executeCommand("ResizeSelectedBrushesToBounds",
Expand All @@ -132,6 +140,7 @@ MouseTool::Result BrushCreatorTool::onMouseUp(Event& ev)
dynamic_cast<XYMouseToolEvent&>(ev).getScale();

GlobalUndoSystem().finish("brushDragNew");
_brush.reset();

return Result::Finished;
}
Expand Down

0 comments on commit 9c6ac11

Please sign in to comment.