Fix renaming item error handling

This commit is contained in:
stefnotch
2020-12-20 19:19:30 +01:00
parent 0da02b99cc
commit 9c55518744

View File

@@ -344,7 +344,13 @@ namespace FlaxEditor.Modules
return null;
}
private static void RenameAsset(ContentItem el, ref string newPath)
/// <summary>
/// Renames a content item
/// </summary>
/// <param name="el">Content item</param>
/// <param name="newPath">New path</param>
/// <returns>True if failed, otherwise false</returns>
private static bool RenameAsset(ContentItem el, ref string newPath)
{
string oldPath = el.Path;
@@ -357,7 +363,7 @@ namespace FlaxEditor.Modules
{
// Error
Editor.LogError(string.Format("Cannot rename asset \'{0}\' to \'{1}\'", oldPath, newPath));
return;
return true;
}
}
else
@@ -372,12 +378,13 @@ namespace FlaxEditor.Modules
// Error
Editor.LogWarning(ex);
Editor.LogError(string.Format("Cannot rename asset \'{0}\' to \'{1}\'", oldPath, newPath));
return;
return true;
}
}
// Change path
el.UpdatePath(newPath);
return false;
}
private static void UpdateAssetNewNameTree(ContentItem el)
@@ -520,7 +527,11 @@ namespace FlaxEditor.Modules
}
else
{
RenameAsset(item, ref newPath);
if (RenameAsset(item, ref newPath))
{
MessageBox.Show("Cannot rename item.");
return;
}
}
if (item.ParentFolder != null)