Fixed a potential crash when undoing while having slope handle picking enabled

This commit is contained in:
biwa 2020-05-30 16:41:05 +02:00
parent c164139d5e
commit 82f019b8bd
2 changed files with 41 additions and 2 deletions

View file

@ -1187,14 +1187,27 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
allslopehandles.Clear();
if (General.Map.UDMF /* && General.Settings.ShowVisualSlopeHandles */)
BuildSlopeHandles(General.Map.Map.Sectors.ToList());
}
private void BuildSlopeHandles(List<Sector> sectors)
{
if (General.Map.UDMF)
{
foreach (Sector s in General.Map.Map.Sectors)
foreach (Sector s in sectors)
{
if (s.IsDisposed)
{
continue;
}
SectorData sectordata = GetSectorData(s);
sectordata.Update();
if (allslopehandles.ContainsKey(s))
allslopehandles.Remove(s);
foreach (Sidedef sidedef in s.Sidedefs)
{
VisualSlope handle = CreateVisualSlopeHandle(sectordata.Floor, sidedef, true);
@ -1489,6 +1502,29 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
// Let the core do this (it will just dispose the sectors that were changed)
base.ResourcesReloadedPartial();
// The base doesn't know anything about slobe handles, so we have to clear them up ourself
if (General.Map.UDMF)
{
List<Sector> removedsectors = new List<Sector>();
// Get the sectors that were disposed...
foreach(Sector s in allslopehandles.Keys)
{
if (s.IsDisposed)
removedsectors.Add(s);
}
// ... so that we can remove their slope handles
foreach(Sector s in removedsectors)
{
allslopehandles[s].Clear();
allslopehandles.Remove(s);
}
// Rebuild slope handles for the changed sectors
BuildSlopeHandles(General.Map.Map.GetMarkedSectors(true));
}
}
else
{

View file

@ -84,6 +84,9 @@ namespace CodeImp.DoomBuilder.VisualModes
/// </summary>
public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir)
{
if (sidedef.IsDisposed || sidedef.Sector.IsDisposed)
return false;
RectangleF bbox = sidedef.Sector.BBox;
if ((up && plane.Distance(from) > 0.0f) || (!up && plane.Distance(from) < 0.0f))