Skip to content

Commit

Permalink
Fix crash when item is already in a view
Browse files Browse the repository at this point in the history
  • Loading branch information
mafiesto4 committed Oct 13, 2023
1 parent d0fbf12 commit db52be5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 8 additions & 6 deletions Source/Editor/Content/GUI/ContentView.cs
Expand Up @@ -220,8 +220,9 @@ public void ClearItems()
// Remove references and unlink items
for (int i = 0; i < _items.Count; i++)
{
_items[i].Parent = null;
_items[i].RemoveReference(this);
var item = _items[i];
item.Parent = null;
item.RemoveReference(this);
}
_items.Clear();

Expand Down Expand Up @@ -263,11 +264,12 @@ public void ShowItems(List<ContentItem> items, SortType sortType, bool additive
// Add references and link items
for (int i = 0; i < items.Count; i++)
{
if (items[i].Visible)
var item = items[i];
if (item.Visible && !_items.Contains(item))
{
items[i].Parent = this;
items[i].AddReference(this);
_items.Add(items[i]);
item.Parent = this;
item.AddReference(this);
_items.Add(item);
}
}
if (selection != null)
Expand Down
2 changes: 0 additions & 2 deletions Source/Editor/Content/Items/ContentItem.cs
Expand Up @@ -323,8 +323,6 @@ protected ContentItem(string path)
/// <param name="value">The new path.</param>
internal virtual void UpdatePath(string value)
{
Assert.AreNotEqual(Path, value);

// Set path
Path = StringUtils.NormalizePath(value);
FileName = System.IO.Path.GetFileName(value);
Expand Down

0 comments on commit db52be5

Please sign in to comment.