From cf8c679a23b21d6c6f29cba6a54eaa2eed88bf92 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Wed, 12 Feb 2020 14:24:06 -0300 Subject: ObjectID converted to a structure, fixes many bugs where used incorrectly as 32 bits. --- editor/dictionary_property_edit.cpp | 1 - editor/editor_data.cpp | 14 ++++++------ editor/editor_node.cpp | 8 +++---- editor/editor_properties.cpp | 10 ++++----- editor/editor_sectioned_inspector.cpp | 3 +-- editor/inspector_dock.cpp | 12 +++++----- editor/plugins/animation_tree_editor_plugin.cpp | 7 +++--- editor/plugins/canvas_item_editor_plugin.cpp | 2 +- editor/plugins/spatial_editor_plugin.cpp | 30 ++++++++++++------------- editor/property_editor.cpp | 8 +++---- editor/property_selector.cpp | 12 +++++----- editor/script_editor_debugger.cpp | 13 +++++------ 12 files changed, 58 insertions(+), 62 deletions(-) (limited to 'editor') diff --git a/editor/dictionary_property_edit.cpp b/editor/dictionary_property_edit.cpp index bb01fadb72..82db639379 100644 --- a/editor/dictionary_property_edit.cpp +++ b/editor/dictionary_property_edit.cpp @@ -190,5 +190,4 @@ bool DictionaryPropertyEdit::_get(const StringName &p_name, Variant &r_ret) cons } DictionaryPropertyEdit::DictionaryPropertyEdit() { - obj = 0; } diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index d7c610f109..5cb7720170 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -156,8 +156,8 @@ bool EditorHistory::is_history_obj_inspector_only(int p_obj) const { } ObjectID EditorHistory::get_history_obj(int p_obj) const { - ERR_FAIL_INDEX_V(p_obj, history.size(), 0); - ERR_FAIL_INDEX_V(history[p_obj].level, history[p_obj].path.size(), 0); + ERR_FAIL_INDEX_V(p_obj, history.size(), ObjectID()); + ERR_FAIL_INDEX_V(history[p_obj].level, history[p_obj].path.size(), ObjectID()); return history[p_obj].path[history[p_obj].level].object; } @@ -204,12 +204,12 @@ bool EditorHistory::is_current_inspector_only() const { ObjectID EditorHistory::get_current() { if (current < 0 || current >= history.size()) - return 0; + return ObjectID(); History &h = history.write[current]; Object *obj = ObjectDB::get_instance(h.path[h.level].object); if (!obj) - return 0; + return ObjectID(); return obj->get_instance_id(); } @@ -226,15 +226,15 @@ int EditorHistory::get_path_size() const { ObjectID EditorHistory::get_path_object(int p_index) const { if (current < 0 || current >= history.size()) - return 0; + return ObjectID(); const History &h = history[current]; - ERR_FAIL_INDEX_V(p_index, h.path.size(), 0); + ERR_FAIL_INDEX_V(p_index, h.path.size(), ObjectID()); Object *obj = ObjectDB::get_instance(h.path[p_index].object); if (!obj) - return 0; + return ObjectID(); return obj->get_instance_id(); } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 4440a747be..a6172faeaa 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -1558,7 +1558,7 @@ void EditorNode::_dialog_action(String p_file) { save_resource_in_path(saving_resource, p_file); saving_resource = Ref(); ObjectID current = editor_history.get_current(); - Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL; + Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : NULL; ERR_FAIL_COND(!current_obj); current_obj->_change_notify(); } break; @@ -1711,7 +1711,7 @@ void EditorNode::push_item(Object *p_object, const String &p_property, bool p_in return; } - uint32_t id = p_object->get_instance_id(); + ObjectID id = p_object->get_instance_id(); if (id != editor_history.get_current()) { if (p_inspector_only) { @@ -1767,8 +1767,8 @@ static bool overrides_external_editor(Object *p_object) { void EditorNode::_edit_current() { - uint32_t current = editor_history.get_current(); - Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL; + ObjectID current = editor_history.get_current(); + Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : NULL; bool inspector_only = editor_history.is_current_inspector_only(); this->current = current_obj; diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 0794940cb1..905e928c5a 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -388,13 +388,13 @@ void EditorPropertyMember::_property_select() { } else if (hint == MEMBER_METHOD_OF_INSTANCE) { - Object *instance = ObjectDB::get_instance(hint_text.to_int64()); + Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64())); if (instance) selector->select_method_from_instance(instance, current); } else if (hint == MEMBER_METHOD_OF_SCRIPT) { - Object *obj = ObjectDB::get_instance(hint_text.to_int64()); + Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64())); if (Object::cast_to