diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs index c734b3127..a0f2eb044 100644 --- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs +++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs @@ -1042,10 +1042,12 @@ namespace FlaxEditor.Viewport DisposeModes(); _debugDrawData.Dispose(); - //Object.Destroy(ref SelectionOutline); - //Object.Destroy(ref EditorPrimitives); - //Object.Destroy(ref _editorSpritesRenderer); - //Object.Destroy(ref _customSelectionOutline); + if (_task != null) + { + // Release if task is not used to save screenshot for project icon + Object.Destroy(ref _task); + ReleaseResources(); + } base.OnDestroy(); } @@ -1062,7 +1064,6 @@ namespace FlaxEditor.Viewport _task = null; _backBuffer = null; - _editorSpritesRenderer = null; } internal void SaveProjectIconEnd() @@ -1070,9 +1071,19 @@ namespace FlaxEditor.Viewport if (_savedTask) { _savedTask.Enabled = false; + Object.Destroy(_savedTask); + ReleaseResources(); _savedTask = null; } Object.Destroy(ref _savedBackBuffer); } + + private void ReleaseResources() + { + Object.Destroy(ref SelectionOutline); + Object.Destroy(ref EditorPrimitives); + Object.Destroy(ref _editorSpritesRenderer); + Object.Destroy(ref _customSelectionOutline); + } } } diff --git a/Source/Engine/Core/Log.cpp b/Source/Engine/Core/Log.cpp index cb73a79e1..29099ad80 100644 --- a/Source/Engine/Core/Log.cpp +++ b/Source/Engine/Core/Log.cpp @@ -156,9 +156,9 @@ void Log::Logger::Dispose() WriteFloor(); // Close - LogAfterInit = false; if (LogAfterInit) { + LogAfterInit = false; LogFile->Close(); Delete(LogFile); LogFile = nullptr; diff --git a/Source/Engine/Platform/Windows/WindowsFileSystemWatcher.cpp b/Source/Engine/Platform/Windows/WindowsFileSystemWatcher.cpp index 63e610cd1..832fd9bb2 100644 --- a/Source/Engine/Platform/Windows/WindowsFileSystemWatcher.cpp +++ b/Source/Engine/Platform/Windows/WindowsFileSystemWatcher.cpp @@ -182,6 +182,7 @@ WindowsFileSystemWatcher::~WindowsFileSystemWatcher() FileSystemWatchers::ThreadActive = false; QueueUserAPC(FileSystemWatchers::StopProc, FileSystemWatchers::Thread->GetHandle(), 0); FileSystemWatchers::Thread->Join(); + Delete(FileSystemWatchers::Thread); FileSystemWatchers::Thread = nullptr; } FileSystemWatchers::Locker.Unlock(); diff --git a/Source/Engine/Scripting/Scripting.cpp b/Source/Engine/Scripting/Scripting.cpp index 2919ce1ae..7f87178fd 100644 --- a/Source/Engine/Scripting/Scripting.cpp +++ b/Source/Engine/Scripting/Scripting.cpp @@ -518,7 +518,7 @@ void Scripting::Release() module->Destroy(false); } - _nonNativeModules.Clear(); + _nonNativeModules.ClearDelete(); _hasGameModulesLoaded = false; } @@ -619,7 +619,7 @@ void Scripting::Reload(bool canTriggerSceneReload) module->Destroy(true); } modules.Clear(); - _nonNativeModules.Clear(); + _nonNativeModules.ClearDelete(); _hasGameModulesLoaded = false; // Give GC a try to cleanup old user objects and the other mess