From 714cdd84ad59bb9051d8c35ae9a7a9cb529f0052 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sun, 28 Apr 2024 20:47:29 +0300 Subject: [PATCH] Fix error when ContentDatabase gets rebuilt while initializing editor --- Source/Editor/Windows/ContentWindow.cs | 40 +++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Source/Editor/Windows/ContentWindow.cs b/Source/Editor/Windows/ContentWindow.cs index 6089b2e07..f30b9b0b6 100644 --- a/Source/Editor/Windows/ContentWindow.cs +++ b/Source/Editor/Windows/ContentWindow.cs @@ -144,26 +144,6 @@ namespace FlaxEditor.Windows FlaxEditor.Utilities.Utils.SetupCommonInputActions(this); - // Content database events - editor.ContentDatabase.WorkspaceModified += () => _isWorkspaceDirty = true; - editor.ContentDatabase.ItemRemoved += OnContentDatabaseItemRemoved; - editor.ContentDatabase.WorkspaceRebuilding += () => { _workspaceRebuildLocation = SelectedNode?.Path; }; - editor.ContentDatabase.WorkspaceRebuilt += () => - { - var selected = Editor.ContentDatabase.Find(_workspaceRebuildLocation); - if (selected is ContentFolder selectedFolder) - { - _navigationUnlocked = false; - RefreshView(selectedFolder.Node); - _tree.Select(selectedFolder.Node); - UpdateItemsSearch(); - _navigationUnlocked = true; - UpdateUI(); - } - else - ShowRoot(); - }; - var options = Editor.Options; options.OptionsChanged += OnOptionsChanged; @@ -1037,6 +1017,26 @@ namespace FlaxEditor.Windows /// public override void OnInit() { + // Content database events + Editor.ContentDatabase.WorkspaceModified += () => _isWorkspaceDirty = true; + Editor.ContentDatabase.ItemRemoved += OnContentDatabaseItemRemoved; + Editor.ContentDatabase.WorkspaceRebuilding += () => { _workspaceRebuildLocation = SelectedNode?.Path; }; + Editor.ContentDatabase.WorkspaceRebuilt += () => + { + var selected = Editor.ContentDatabase.Find(_workspaceRebuildLocation); + if (selected is ContentFolder selectedFolder) + { + _navigationUnlocked = false; + RefreshView(selectedFolder.Node); + _tree.Select(selectedFolder.Node); + UpdateItemsSearch(); + _navigationUnlocked = true; + UpdateUI(); + } + else if (_root != null) + ShowRoot(); + }; + // Setup content root node _root = new RootContentTreeNode {