You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +00:00
Fix Skeleton3DEditor causing crash in sanitizer enabled builds
The life cycle of the `Skeleton3DEditor` singleton is too short, and when it is destroyed, part of the logic needs to be called when its child nodes exist.
This commit is contained in:
@@ -852,6 +852,20 @@ void Skeleton3DEditor::_notification(int p_what) {
|
|||||||
|
|
||||||
update_joint_tree();
|
update_joint_tree();
|
||||||
} break;
|
} break;
|
||||||
|
case NOTIFICATION_PREDELETE: {
|
||||||
|
if (skeleton) {
|
||||||
|
select_bone(-1); // Requires that the joint_tree has not been deleted.
|
||||||
|
#ifdef TOOLS_ENABLED
|
||||||
|
skeleton->disconnect("show_rest_only_changed", callable_mp(this, &Skeleton3DEditor::_update_gizmo_visible));
|
||||||
|
skeleton->disconnect("bone_enabled_changed", callable_mp(this, &Skeleton3DEditor::_bone_enabled_changed));
|
||||||
|
skeleton->disconnect("pose_updated", callable_mp(this, &Skeleton3DEditor::_draw_gizmo));
|
||||||
|
skeleton->disconnect("pose_updated", callable_mp(this, &Skeleton3DEditor::_update_properties));
|
||||||
|
skeleton->set_transform_gizmo_visible(true);
|
||||||
|
#endif
|
||||||
|
handles_mesh_instance->get_parent()->remove_child(handles_mesh_instance);
|
||||||
|
}
|
||||||
|
edit_mode_toggled(false);
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1066,18 +1080,7 @@ void Skeleton3DEditor::select_bone(int p_idx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Skeleton3DEditor::~Skeleton3DEditor() {
|
Skeleton3DEditor::~Skeleton3DEditor() {
|
||||||
if (skeleton) {
|
singleton = nullptr;
|
||||||
select_bone(-1);
|
|
||||||
#ifdef TOOLS_ENABLED
|
|
||||||
skeleton->disconnect("show_rest_only_changed", callable_mp(this, &Skeleton3DEditor::_update_gizmo_visible));
|
|
||||||
skeleton->disconnect("bone_enabled_changed", callable_mp(this, &Skeleton3DEditor::_bone_enabled_changed));
|
|
||||||
skeleton->disconnect("pose_updated", callable_mp(this, &Skeleton3DEditor::_draw_gizmo));
|
|
||||||
skeleton->disconnect("pose_updated", callable_mp(this, &Skeleton3DEditor::_update_properties));
|
|
||||||
skeleton->set_transform_gizmo_visible(true);
|
|
||||||
#endif
|
|
||||||
handles_mesh_instance->get_parent()->remove_child(handles_mesh_instance);
|
|
||||||
}
|
|
||||||
edit_mode_toggled(false);
|
|
||||||
|
|
||||||
handles_mesh_instance->queue_delete();
|
handles_mesh_instance->queue_delete();
|
||||||
|
|
||||||
@@ -1128,7 +1131,7 @@ Skeleton3DEditorPlugin::Skeleton3DEditorPlugin() {
|
|||||||
EditorPlugin::AfterGUIInput Skeleton3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
|
EditorPlugin::AfterGUIInput Skeleton3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
|
||||||
Skeleton3DEditor *se = Skeleton3DEditor::get_singleton();
|
Skeleton3DEditor *se = Skeleton3DEditor::get_singleton();
|
||||||
Node3DEditor *ne = Node3DEditor::get_singleton();
|
Node3DEditor *ne = Node3DEditor::get_singleton();
|
||||||
if (se->is_edit_mode()) {
|
if (se && se->is_edit_mode()) {
|
||||||
const Ref<InputEventMouseButton> mb = p_event;
|
const Ref<InputEventMouseButton> mb = p_event;
|
||||||
if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT) {
|
if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT) {
|
||||||
if (ne->get_tool_mode() != Node3DEditor::TOOL_MODE_SELECT) {
|
if (ne->get_tool_mode() != Node3DEditor::TOOL_MODE_SELECT) {
|
||||||
|
|||||||
Reference in New Issue
Block a user