From 9c555187440cda6abfa0adcf58272bd11252820f Mon Sep 17 00:00:00 2001 From: stefnotch Date: Sun, 20 Dec 2020 19:19:30 +0100 Subject: [PATCH] Fix renaming item error handling --- .../Editor/Modules/ContentDatabaseModule.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Source/Editor/Modules/ContentDatabaseModule.cs b/Source/Editor/Modules/ContentDatabaseModule.cs index f0fa8022a..f270f119f 100644 --- a/Source/Editor/Modules/ContentDatabaseModule.cs +++ b/Source/Editor/Modules/ContentDatabaseModule.cs @@ -344,7 +344,13 @@ namespace FlaxEditor.Modules return null; } - private static void RenameAsset(ContentItem el, ref string newPath) + /// + /// Renames a content item + /// + /// Content item + /// New path + /// True if failed, otherwise false + 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)