Skip to content

Commit 11324c3

Browse files
authored
Merge pull request #886 from DomCR/issue-881_npe-in-blockrecordgetsortedentities
issue 881
2 parents 0c8d311 + 23b0cb0 commit 11324c3

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/ACadSharp.Tests/Tables/BlockRecordTests.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ public void CloneSortensTableTest()
128128

129129
var sorted = record.GetSortedEntities().ToArray();
130130

131+
Assert.NotNull(record.SortEntitiesTable);
132+
Assert.NotEmpty(record.SortEntitiesTable);
133+
Assert.Equal(4, record.SortEntitiesTable.Count());
134+
131135
Assert.Equal(l1, sorted[0]);
132136
Assert.Equal(l3, sorted[1]);
133137
Assert.Equal(l5, sorted[2]);
@@ -138,7 +142,7 @@ public void CloneSortensTableTest()
138142

139143
Assert.NotNull(clone.SortEntitiesTable);
140144
Assert.NotEmpty(clone.SortEntitiesTable);
141-
Assert.Equal(4, clone.SortEntitiesTable.Count());
145+
Assert.Equal(5, clone.SortEntitiesTable.Count());
142146

143147
sorted = clone.GetSortedEntities().ToArray();
144148

src/ACadSharp/ACadSharp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<PropertyGroup>
1818
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1919
<PackageReadmeFile>README.md</PackageReadmeFile>
20-
<Version>3.2.48</Version>
20+
<Version>3.2.49</Version>
2121
<PackageOutputPath>../nupkg</PackageOutputPath>
2222
</PropertyGroup>
2323

src/ACadSharp/Tables/BlockRecord.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,7 @@ public override CadObject Clone()
372372

373373
if (this.SortEntitiesTable != null)
374374
{
375-
clone.XDictionary.Remove(SortEntitiesTable.DictionaryEntryName);
376-
clone.CreateSortEntitiesTable();
375+
clone.SortEntitiesTable.BlockOwner = clone;
377376
}
378377

379378
clone.Entities = new CadObjectCollection<Entity>(clone);
@@ -382,8 +381,7 @@ public override CadObject Clone()
382381
var e = (Entity)item.Clone();
383382
clone.Entities.Add(e);
384383

385-
if (this.SortEntitiesTable != null
386-
&& this.SortEntitiesTable.Select(s => s.Entity).Contains(item))
384+
if (this.SortEntitiesTable != null)
387385
{
388386
clone.SortEntitiesTable.Add(e, this.SortEntitiesTable.GetSorterHandle(item));
389387
}
@@ -464,7 +462,6 @@ public IEnumerable<Entity> GetSortedEntities()
464462
}
465463

466464
List<(ulong, Entity)> entities = new();
467-
468465
foreach (var entity in this.Entities)
469466
{
470467
ulong sorter = this.SortEntitiesTable.GetSorterHandle(entity);

0 commit comments

Comments
 (0)