Fix various memory leaks on exit
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,9 +156,9 @@ void Log::Logger::Dispose()
|
||||
WriteFloor();
|
||||
|
||||
// Close
|
||||
LogAfterInit = false;
|
||||
if (LogAfterInit)
|
||||
{
|
||||
LogAfterInit = false;
|
||||
LogFile->Close();
|
||||
Delete(LogFile);
|
||||
LogFile = nullptr;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user