From b5d8009bec2d242674624a728af342150053c7d1 Mon Sep 17 00:00:00 2001 From: Misaki Date: Sun, 29 Mar 2026 01:13:51 +0900 Subject: [PATCH] Fixed the issue that crash when close. --- .../Ghost.Editor.Core.csproj | 8 ++--- .../Services/NotificationService.cs | 4 --- .../Ghost.Editor.Core/Utilities/TypeCache.cs | 2 +- src/Editor/Ghost.Editor/ActivationHandler.cs | 17 ++++++----- src/Editor/Ghost.Editor/App.xaml.cs | 7 ++++- src/Editor/Ghost.Editor/Ghost.Editor.csproj | 10 +++++-- .../View/Controls/Docking/DockGroup.xaml | 13 +++++---- .../View/Controls/ProjectBrowser.xaml | 2 ++ .../View/Windows/BlankWindow1.xaml | 17 +++++++++++ .../View/Windows/BlankWindow1.xaml.cs | 29 +++++++++++++++++++ .../View/Windows/EngineEditorWindow.xaml | 8 +++-- src/Runtime/Ghost.Engine/EngineCore.cs | 3 +- 12 files changed, 90 insertions(+), 30 deletions(-) create mode 100644 src/Editor/Ghost.Editor/View/Windows/BlankWindow1.xaml create mode 100644 src/Editor/Ghost.Editor/View/Windows/BlankWindow1.xaml.cs diff --git a/src/Editor/Ghost.Editor.Core/Ghost.Editor.Core.csproj b/src/Editor/Ghost.Editor.Core/Ghost.Editor.Core.csproj index 9112519..ce014ae 100644 --- a/src/Editor/Ghost.Editor.Core/Ghost.Editor.Core.csproj +++ b/src/Editor/Ghost.Editor.Core/Ghost.Editor.Core.csproj @@ -13,10 +13,10 @@ preview - - - - + + + + diff --git a/src/Editor/Ghost.Editor.Core/Services/NotificationService.cs b/src/Editor/Ghost.Editor.Core/Services/NotificationService.cs index aa0374c..cdc2656 100644 --- a/src/Editor/Ghost.Editor.Core/Services/NotificationService.cs +++ b/src/Editor/Ghost.Editor.Core/Services/NotificationService.cs @@ -41,10 +41,6 @@ public class NotificationService : INotificationService internal void ClearReference() { - if (_infoBar != null) - { - _infoBar.IsOpen = false; - } _infoBar = null; _notificationQueue = null; } diff --git a/src/Editor/Ghost.Editor.Core/Utilities/TypeCache.cs b/src/Editor/Ghost.Editor.Core/Utilities/TypeCache.cs index b2ec4dc..d0df615 100644 --- a/src/Editor/Ghost.Editor.Core/Utilities/TypeCache.cs +++ b/src/Editor/Ghost.Editor.Core/Utilities/TypeCache.cs @@ -62,7 +62,7 @@ public static class TypeCache return dict; } - internal static void Init() + internal static void Initialize() { // Intentionally left blank. // This method exists to force the static constructor to run. diff --git a/src/Editor/Ghost.Editor/ActivationHandler.cs b/src/Editor/Ghost.Editor/ActivationHandler.cs index 9d1e80c..5e1ae47 100644 --- a/src/Editor/Ghost.Editor/ActivationHandler.cs +++ b/src/Editor/Ghost.Editor/ActivationHandler.cs @@ -1,6 +1,5 @@ using Ghost.Editor.Core.Utilities; using Ghost.Editor.Models; -using Ghost.Engine; using Misaki.HighPerformance.LowLevel.Buffer; using System.Reflection; @@ -52,7 +51,7 @@ internal static class ActivationHandler return arguments; } - public static async Task HandleAsync(LaunchArguments args) + public static ValueTask HandleAsync(LaunchArguments args) { var opts = new AllocationManagerInitOpts { @@ -62,16 +61,18 @@ internal static class ActivationHandler }; AllocationManager.Initialize(opts); - - await Task.Run(() => - { - TypeCache.Init(); - App.GetService(); - }); + TypeCache.Initialize(); // await ((Core.AssetHandle.AssetService)App.GetService()).Init(); // TODO: Init other subsystems here. // await Task.Delay(10000); // Wait 10 seconds to simulate work. + + return ValueTask.CompletedTask; + } + + public static void Shutdown() + { + AllocationManager.Dispose(); } } \ No newline at end of file diff --git a/src/Editor/Ghost.Editor/App.xaml.cs b/src/Editor/Ghost.Editor/App.xaml.cs index 5a62383..f64375e 100644 --- a/src/Editor/Ghost.Editor/App.xaml.cs +++ b/src/Editor/Ghost.Editor/App.xaml.cs @@ -144,12 +144,17 @@ public partial class App : Application Host.StopAsync().GetAwaiter().GetResult(); Host.Dispose(); - EditorApplication.Shutdown(); + //EditorApplication.Shutdown(); + ActivationHandler.Shutdown(); } catch (Exception ex) { Debugger.BreakForUserUnhandledException(ex); } + finally + { + //Environment.Exit(0); + } } private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e) diff --git a/src/Editor/Ghost.Editor/Ghost.Editor.csproj b/src/Editor/Ghost.Editor/Ghost.Editor.csproj index c59202d..ac58f70 100644 --- a/src/Editor/Ghost.Editor/Ghost.Editor.csproj +++ b/src/Editor/Ghost.Editor/Ghost.Editor.csproj @@ -13,6 +13,7 @@ + @@ -38,10 +39,10 @@ - + - - + + @@ -141,6 +142,9 @@ PreserveNewest + + MSBuild:Compile + MSBuild:Compile diff --git a/src/Editor/Ghost.Editor/View/Controls/Docking/DockGroup.xaml b/src/Editor/Ghost.Editor/View/Controls/Docking/DockGroup.xaml index 208fc00..4429cb8 100644 --- a/src/Editor/Ghost.Editor/View/Controls/Docking/DockGroup.xaml +++ b/src/Editor/Ghost.Editor/View/Controls/Docking/DockGroup.xaml @@ -8,12 +8,13 @@ - - + diff --git a/src/Editor/Ghost.Editor/View/Controls/ProjectBrowser.xaml b/src/Editor/Ghost.Editor/View/Controls/ProjectBrowser.xaml index 4753ed7..959502a 100644 --- a/src/Editor/Ghost.Editor/View/Controls/ProjectBrowser.xaml +++ b/src/Editor/Ghost.Editor/View/Controls/ProjectBrowser.xaml @@ -144,6 +144,8 @@ DoubleTapped="PART_FilesView_DoubleTapped" IsDoubleTapEnabled="True" ItemsSource="{x:Bind ViewModel.Files, Mode=OneWay}" + ScrollViewer.HorizontalScrollBarVisibility="Disabled" + ScrollViewer.HorizontalScrollMode="Disabled" SelectionChanged="PART_FilesView_SelectionChanged" SelectionMode="Single"> diff --git a/src/Editor/Ghost.Editor/View/Windows/BlankWindow1.xaml b/src/Editor/Ghost.Editor/View/Windows/BlankWindow1.xaml new file mode 100644 index 0000000..8724d0a --- /dev/null +++ b/src/Editor/Ghost.Editor/View/Windows/BlankWindow1.xaml @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/src/Editor/Ghost.Editor/View/Windows/BlankWindow1.xaml.cs b/src/Editor/Ghost.Editor/View/Windows/BlankWindow1.xaml.cs new file mode 100644 index 0000000..d3cdbee --- /dev/null +++ b/src/Editor/Ghost.Editor/View/Windows/BlankWindow1.xaml.cs @@ -0,0 +1,29 @@ +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; + +// To learn more about WinUI, the WinUI project structure, +// and more about our project templates, see: http://aka.ms/winui-project-info. + +namespace Ghost.Editor.View.Windows; +/// +/// An empty window that can be used on its own or navigated to within a Frame. +/// +public sealed partial class BlankWindow1 : Window +{ + public BlankWindow1() + { + InitializeComponent(); + } +} diff --git a/src/Editor/Ghost.Editor/View/Windows/EngineEditorWindow.xaml b/src/Editor/Ghost.Editor/View/Windows/EngineEditorWindow.xaml index 206574b..a78ad25 100644 --- a/src/Editor/Ghost.Editor/View/Windows/EngineEditorWindow.xaml +++ b/src/Editor/Ghost.Editor/View/Windows/EngineEditorWindow.xaml @@ -64,8 +64,12 @@ + + + + - + _jobScheduler; public RenderSystem RenderSystem => _renderSystem; - internal EngineCore() + public EngineCore() { _jobScheduler = new JobScheduler(Environment.ProcessorCount - 2); // We -2 here, one for main thread, one for render thread @@ -35,6 +35,7 @@ public sealed partial class EngineCore : IDisposable public void Dispose() { + _renderSystem.Dispose(); _jobScheduler.Dispose(); } }