Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed _change_notify(property) #45879

Merged
merged 1 commit into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/core_string_names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,6 @@ CoreStringNames::CoreStringNames() :
bind(StaticCString::create("bind")),
unbind(StaticCString::create("unbind")),
emit(StaticCString::create("emit")),
notification(StaticCString::create("notification")) {
notification(StaticCString::create("notification")),
property_list_changed(StaticCString::create("property_list_changed")) {
}
1 change: 1 addition & 0 deletions core/core_string_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class CoreStringNames {
StringName unbind;
StringName emit;
StringName notification;
StringName property_list_changed;
};

#endif // CORE_STRING_NAMES_H
2 changes: 0 additions & 2 deletions core/io/resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ void Resource::set_path(const String &p_path, bool p_take_over) {
ResourceCache::lock.write_unlock();
}

_change_notify("resource_path");
_resource_path_changed();
}

Expand All @@ -105,7 +104,6 @@ int Resource::get_subindex() const {

void Resource::set_name(const String &p_name) {
name = p_name;
_change_notify("resource_name");
}

String Resource::get_name() const {
Expand Down
24 changes: 7 additions & 17 deletions core/object/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,21 +808,6 @@ String Object::to_string() {
return "[" + get_class() + ":" + itos(get_instance_id()) + "]";
}

void Object::_changed_callback(Object *p_changed, const char *p_prop) {
}

void Object::add_change_receptor(Object *p_receptor) {
change_receptors.insert(p_receptor);
}

void Object::remove_change_receptor(Object *p_receptor) {
change_receptors.erase(p_receptor);
}

void Object::property_list_changed_notify() {
_change_notify();
}

void Object::set_script_and_instance(const Variant &p_script, ScriptInstance *p_instance) {
//this function is not meant to be used in any of these ways
ERR_FAIL_COND(p_script.is_null());
Expand Down Expand Up @@ -856,7 +841,7 @@ void Object::set_script(const Variant &p_script) {
}
}

_change_notify(); //scripts may add variables, so refresh is desired
notify_property_list_changed(); //scripts may add variables, so refresh is desired
emit_signal(CoreStringNames::get_singleton()->script_changed);
}

Expand Down Expand Up @@ -1496,6 +1481,10 @@ void Object::clear_internal_resource_paths() {
}
}

void Object::notify_property_list_changed() {
emit_signal(CoreStringNames::get_singleton()->property_list_changed);
}

void Object::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_class"), &Object::get_class);
ClassDB::bind_method(D_METHOD("is_class", "class"), &Object::is_class);
Expand Down Expand Up @@ -1562,7 +1551,7 @@ void Object::_bind_methods() {

ClassDB::bind_method(D_METHOD("set_block_signals", "enable"), &Object::set_block_signals);
ClassDB::bind_method(D_METHOD("is_blocking_signals"), &Object::is_blocking_signals);
ClassDB::bind_method(D_METHOD("property_list_changed_notify"), &Object::property_list_changed_notify);
ClassDB::bind_method(D_METHOD("notify_property_list_changed"), &Object::notify_property_list_changed);

ClassDB::bind_method(D_METHOD("set_message_translation", "enable"), &Object::set_message_translation);
ClassDB::bind_method(D_METHOD("can_translate_messages"), &Object::can_translate_messages);
Expand All @@ -1574,6 +1563,7 @@ void Object::_bind_methods() {
ClassDB::add_virtual_method("Object", MethodInfo("free"), false);

ADD_SIGNAL(MethodInfo("script_changed"));
ADD_SIGNAL(MethodInfo("property_list_changed"));

BIND_VMETHOD(MethodInfo("_notification", PropertyInfo(Variant::INT, "what")));
BIND_VMETHOD(MethodInfo(Variant::BOOL, "_set", PropertyInfo(Variant::STRING_NAME, "property"), PropertyInfo(Variant::NIL, "value")));
Expand Down
20 changes: 2 additions & 18 deletions core/object/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ class Object {
#endif
bool _block_signals = false;
int _predelete_ok = 0;
Set<Object *> change_receptors;
ObjectID _instance_id;
bool _predelete();
void _postinitialize();
Expand Down Expand Up @@ -523,9 +522,6 @@ class Object {
static void get_valid_parents_static(List<String> *p_parents);
static void _get_valid_parents_static(List<String> *p_parents);

void property_list_changed_notify();
virtual void _changed_callback(Object *p_changed, const char *p_prop);

//Variant _call_bind(const StringName& p_name, const Variant& p_arg1 = Variant(), const Variant& p_arg2 = Variant(), const Variant& p_arg3 = Variant(), const Variant& p_arg4 = Variant());
//void _call_deferred_bind(const StringName& p_name, const Variant& p_arg1 = Variant(), const Variant& p_arg2 = Variant(), const Variant& p_arg3 = Variant(), const Variant& p_arg4 = Variant());

Expand Down Expand Up @@ -555,16 +551,8 @@ class Object {
_FORCE_INLINE_ static void register_custom_data_to_otdb() {}

public:
#ifdef TOOLS_ENABLED
_FORCE_INLINE_ void _change_notify(const char *p_property = "") {
_edited = true;
for (Set<Object *>::Element *E = change_receptors.front(); E; E = E->next()) {
((Object *)(E->get()))->_changed_callback(this, p_property);
}
}
#else
_FORCE_INLINE_ void _change_notify(const char *p_what = "") {}
#endif
void notify_property_list_changed();

static void *get_class_ptr_static() {
static int ptr;
return &ptr;
Expand All @@ -574,10 +562,6 @@ class Object {

_FORCE_INLINE_ ObjectID get_instance_id() const { return _instance_id; }

// this is used for editors
void add_change_receptor(Object *p_receptor);
void remove_change_receptor(Object *p_receptor);

template <class T>
static T *cast_to(Object *p_object) {
#ifndef NO_SAFE_CAST
Expand Down
2 changes: 1 addition & 1 deletion core/object/script_language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ void PlaceHolderScriptInstance::update(const List<PropertyInfo> &p_properties, c
}

if (owner && owner->get_script_instance() == this) {
owner->_change_notify();
owner->notify_property_list_changed();
}
//change notify

Expand Down
9 changes: 4 additions & 5 deletions editor/animation_track_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ class AnimationTrackKeyEdit : public Object {
bool use_fps = false;

void notify_change() {
_change_notify();
notify_property_list_changed();
}

Node *get_root_path() {
Expand All @@ -643,7 +643,7 @@ class AnimationTrackKeyEdit : public Object {

void set_use_fps(bool p_enable) {
use_fps = p_enable;
_change_notify();
notify_property_list_changed();
}
};

Expand Down Expand Up @@ -1276,7 +1276,7 @@ class AnimationMultiTrackKeyEdit : public Object {
UndoRedo *undo_redo = nullptr;

void notify_change() {
_change_notify();
notify_property_list_changed();
}

Node *get_root_path() {
Expand All @@ -1285,7 +1285,7 @@ class AnimationMultiTrackKeyEdit : public Object {

void set_use_fps(bool p_enable) {
use_fps = p_enable;
_change_notify();
notify_property_list_changed();
}
};

Expand Down Expand Up @@ -4283,7 +4283,6 @@ void AnimationTrackEditor::_animation_update() {
_update_step_spinbox();
emit_signal("animation_step_changed", animation->get_step());
emit_signal("animation_len_changed", animation->get_length());
EditorNode::get_singleton()->get_inspector()->refresh();

animation_changing_awaiting_update = false;
}
Expand Down
11 changes: 2 additions & 9 deletions editor/array_property_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ Variant ArrayPropertyEdit::get_array() const {
}

void ArrayPropertyEdit::_notif_change() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not necessarily to do in this PR, but I guess we could remove _notif_change here and in DictionaryPropertyEdit and use notify_property_list_changed directly in the UndoRedo code which currently uses _notif_change.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if these classes are still in use, i have the feeling they are not. Probably in another PR they should be removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since now there are EditorProperty based editor for arrays and dictionaries.

_change_notify();
}

void ArrayPropertyEdit::_notif_changev(const String &p_v) {
_change_notify(p_v.utf8().get_data());
notify_property_list_changed();
}

void ArrayPropertyEdit::_set_size(int p_size) {
Expand Down Expand Up @@ -120,7 +116,7 @@ bool ArrayPropertyEdit::_set(const StringName &p_name, const Variant &p_value) {
}
if (pn == "array/page") {
page = p_value;
_change_notify();
notify_property_list_changed();
return true;
}

Expand Down Expand Up @@ -159,8 +155,6 @@ bool ArrayPropertyEdit::_set(const StringName &p_name, const Variant &p_value) {
ur->create_action(TTR("Change Array Value"));
ur->add_do_method(this, "_set_value", idx, p_value);
ur->add_undo_method(this, "_set_value", idx, value);
ur->add_do_method(this, "_notif_changev", p_name);
ur->add_undo_method(this, "_notif_changev", p_name);
ur->commit_action();
return true;
}
Expand Down Expand Up @@ -288,7 +282,6 @@ void ArrayPropertyEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("_set_size"), &ArrayPropertyEdit::_set_size);
ClassDB::bind_method(D_METHOD("_set_value"), &ArrayPropertyEdit::_set_value);
ClassDB::bind_method(D_METHOD("_notif_change"), &ArrayPropertyEdit::_notif_change);
ClassDB::bind_method(D_METHOD("_notif_changev"), &ArrayPropertyEdit::_notif_changev);
ClassDB::bind_method(D_METHOD("_dont_undo_redo"), &ArrayPropertyEdit::_dont_undo_redo);
}

Expand Down
1 change: 0 additions & 1 deletion editor/array_property_edit.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class ArrayPropertyEdit : public Reference {
Variant::Type default_type;

void _notif_change();
void _notif_changev(const String &p_v);
void _set_size(int p_size);
void _set_value(int p_idx, const Variant &p_value);

Expand Down
2 changes: 1 addition & 1 deletion editor/connections_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class ConnectDialogBinds : public Object {
}

void notify_changed() {
_change_notify();
notify_property_list_changed();
}

ConnectDialogBinds() {
Expand Down
2 changes: 1 addition & 1 deletion editor/debugger/editor_debugger_inspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class EditorDebuggerRemoteObject : public Object {
prop_values.clear();
}

void update() { _change_notify(); }
void update() { notify_property_list_changed(); }

EditorDebuggerRemoteObject() {}
};
Expand Down
11 changes: 1 addition & 10 deletions editor/dictionary_property_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@
#include "editor_node.h"

void DictionaryPropertyEdit::_notif_change() {
_change_notify();
}

void DictionaryPropertyEdit::_notif_changev(const String &p_v) {
_change_notify(p_v.utf8().get_data());
notify_property_list_changed();
}

void DictionaryPropertyEdit::_set_key(const Variant &p_old_key, const Variant &p_new_key) {
Expand Down Expand Up @@ -107,7 +103,6 @@ void DictionaryPropertyEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("_set_key"), &DictionaryPropertyEdit::_set_key);
ClassDB::bind_method(D_METHOD("_set_value"), &DictionaryPropertyEdit::_set_value);
ClassDB::bind_method(D_METHOD("_notif_change"), &DictionaryPropertyEdit::_notif_change);
ClassDB::bind_method(D_METHOD("_notif_changev"), &DictionaryPropertyEdit::_notif_changev);
ClassDB::bind_method(D_METHOD("_dont_undo_redo"), &DictionaryPropertyEdit::_dont_undo_redo);
}

Expand All @@ -128,8 +123,6 @@ bool DictionaryPropertyEdit::_set(const StringName &p_name, const Variant &p_val
ur->create_action(TTR("Change Dictionary Key"));
ur->add_do_method(this, "_set_key", key, p_value);
ur->add_undo_method(this, "_set_key", p_value, key);
ur->add_do_method(this, "_notif_changev", p_name);
ur->add_undo_method(this, "_notif_changev", p_name);
ur->commit_action();

return true;
Expand All @@ -142,8 +135,6 @@ bool DictionaryPropertyEdit::_set(const StringName &p_name, const Variant &p_val
ur->create_action(TTR("Change Dictionary Value"));
ur->add_do_method(this, "_set_value", key, p_value);
ur->add_undo_method(this, "_set_value", key, value);
ur->add_do_method(this, "_notif_changev", p_name);
ur->add_undo_method(this, "_notif_changev", p_name);
ur->commit_action();

return true;
Expand Down
1 change: 0 additions & 1 deletion editor/dictionary_property_edit.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class DictionaryPropertyEdit : public Reference {
StringName property;

void _notif_change();
void _notif_changev(const String &p_v);
void _set_key(const Variant &p_old_key, const Variant &p_new_key);
void _set_value(const Variant &p_key, const Variant &p_value);

Expand Down
Loading