Fix crash when using audio playback and playing editor meanwhile
This commit is contained in:
@@ -606,6 +606,11 @@ void ManagedEditor::WipeOutLeftoverSceneObjects()
|
||||
{
|
||||
if (sceneObject->HasParent())
|
||||
continue; // Skip sub-objects
|
||||
auto* actor = Cast<Actor>(sceneObject);
|
||||
if (!actor)
|
||||
actor = sceneObject->GetParent();
|
||||
if (actor && actor->HasTag(TEXT("__EditorInternal")))
|
||||
continue; // Skip internal objects used by Editor (eg. EditorScene)
|
||||
|
||||
LOG(Error, "Object '{}' (ID={}, Type={}) is still in memory after play end but should be destroyed (memory leak).", sceneObject->GetNamePath(), sceneObject->GetID(), sceneObject->GetType().ToString());
|
||||
sceneObject->DeleteObject();
|
||||
|
||||
@@ -10,6 +10,9 @@ EditorScene::EditorScene(const SpawnParams& params)
|
||||
SceneBeginData beginData;
|
||||
EditorScene::BeginPlay(&beginData);
|
||||
beginData.OnDone();
|
||||
|
||||
// Mark as internal to prevent collection in ManagedEditor::WipeOutLeftoverSceneObjects
|
||||
Tags.Add(Tags::Get(TEXT("__EditorInternal")));
|
||||
}
|
||||
|
||||
void EditorScene::Update()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
|
||||
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using FlaxEditor.Content;
|
||||
using FlaxEditor.Content.Import;
|
||||
|
||||
@@ -732,7 +732,12 @@ Array<ScriptingObject*, HeapAllocation> Scripting::GetObjects()
|
||||
{
|
||||
Array<ScriptingObject*> objects;
|
||||
_objectsLocker.Lock();
|
||||
#if USE_OBJECTS_DISPOSE_CRASHES_DEBUGGING
|
||||
for (const auto& e : _objectsDictionary)
|
||||
objects.Add(e.Value.Ptr);
|
||||
#else
|
||||
_objectsDictionary.GetValues(objects);
|
||||
#endif
|
||||
_objectsLocker.Unlock();
|
||||
return objects;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user