summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/control.cpp4
-rw-r--r--scene/gui/tab_container.cpp10
-rw-r--r--scene/main/node.cpp29
-rw-r--r--scene/resources/packed_scene.cpp25
4 files changed, 22 insertions, 46 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 59cb097b34..dddeec5610 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -1501,7 +1501,7 @@ void Control::_set_layout_mode(LayoutMode p_mode) {
bool list_changed = false;
if (p_mode == LayoutMode::LAYOUT_MODE_POSITION || p_mode == LayoutMode::LAYOUT_MODE_ANCHORS) {
- if (has_meta("_edit_layout_mode") && (int)get_meta("_edit_layout_mode") != (int)p_mode) {
+ if ((int)get_meta("_edit_layout_mode", p_mode) != (int)p_mode) {
list_changed = true;
}
@@ -1646,7 +1646,7 @@ void Control::_set_anchors_layout_preset(int p_preset) {
int Control::_get_anchors_layout_preset() const {
// If the custom preset was selected by user, use it.
- if (has_meta("_edit_use_custom_anchors") && (bool)get_meta("_edit_use_custom_anchors")) {
+ if ((bool)get_meta("_edit_use_custom_anchors", false)) {
return -1;
}
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 3a3a84b481..8299d73b68 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -523,7 +523,7 @@ void TabContainer::move_child_notify(Node *p_child) {
Control *c = Object::cast_to<Control>(p_child);
if (c && !c->is_set_as_top_level()) {
int old_idx = -1;
- String tab_name = c->has_meta("_tab_name") ? String(c->get_meta("_tab_name")) : String(c->get_name());
+ String tab_name = String(c->get_meta("_tab_name", c->get_name()));
// Find the previous tab index of the control.
for (int i = 0; i < get_tab_count(); i++) {
@@ -556,9 +556,7 @@ void TabContainer::remove_child_notify(Node *p_child) {
update();
}
- if (p_child->has_meta("_tab_name")) {
- p_child->remove_meta("_tab_name");
- }
+ p_child->remove_meta("_tab_name");
p_child->disconnect("renamed", callable_mp(this, &TabContainer::_refresh_tab_names));
// TabBar won't emit the "tab_changed" signal when not inside the tree.
@@ -679,9 +677,7 @@ void TabContainer::set_tab_title(int p_tab, const String &p_title) {
tab_bar->set_tab_title(p_tab, p_title);
if (p_title == child->get_name()) {
- if (child->has_meta("_tab_name")) {
- child->remove_meta("_tab_name");
- }
+ child->remove_meta("_tab_name");
} else {
child->set_meta("_tab_name", p_title);
}
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index f549b3dde2..8961b5ba54 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2012,35 +2012,28 @@ Node *Node::get_deepest_editable_node(Node *p_start_node) const {
#ifdef TOOLS_ENABLED
void Node::set_property_pinned(const String &p_property, bool p_pinned) {
bool current_pinned = false;
- bool has_pinned = has_meta("_edit_pinned_properties_");
- Array pinned;
- String psa = get_property_store_alias(p_property);
- if (has_pinned) {
- pinned = get_meta("_edit_pinned_properties_");
- current_pinned = pinned.has(psa);
- }
+ Array pinned = get_meta("_edit_pinned_properties_", Array());
+ StringName psa = get_property_store_alias(p_property);
+ current_pinned = pinned.has(psa);
if (current_pinned != p_pinned) {
if (p_pinned) {
pinned.append(psa);
- if (!has_pinned) {
- set_meta("_edit_pinned_properties_", pinned);
- }
} else {
pinned.erase(psa);
- if (pinned.is_empty()) {
- remove_meta("_edit_pinned_properties_");
- }
}
}
+
+ if (pinned.is_empty()) {
+ remove_meta("_edit_pinned_properties_");
+ } else {
+ set_meta("_edit_pinned_properties_", pinned);
+ }
}
bool Node::is_property_pinned(const StringName &p_property) const {
- if (!has_meta("_edit_pinned_properties_")) {
- return false;
- }
- Array pinned = get_meta("_edit_pinned_properties_");
- String psa = get_property_store_alias(p_property);
+ Array pinned = get_meta("_edit_pinned_properties_", Array());
+ StringName psa = get_property_store_alias(p_property);
return pinned.has(psa);
}
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index f7504974d2..d649942188 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -49,10 +49,7 @@ bool SceneState::can_instantiate() const {
}
static Array _sanitize_node_pinned_properties(Node *p_node) {
- if (!p_node->has_meta("_edit_pinned_properties_")) {
- return Array();
- }
- Array pinned = p_node->get_meta("_edit_pinned_properties_");
+ Array pinned = p_node->get_meta("_edit_pinned_properties_", Array());
if (pinned.is_empty()) {
return Array();
}
@@ -525,29 +522,19 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
continue;
}
- Variant forced_value;
-
if (E.name == META_PROPERTY_MISSING_RESOURCES) {
- continue; //ignore this property when packing
+ continue; // Ignore this property when packing.
}
- // If instance or inheriting, not saving if property requested so, or it's meta
- if (states_stack.size()) {
+ // If instance or inheriting, not saving if property requested so.
+ if (!states_stack.is_empty()) {
if ((E.usage & PROPERTY_USAGE_NO_INSTANCE_STATE)) {
continue;
}
- // Meta is normally not saved in instances/inherited (see GH-12838), but we need to save the pinned list
- if (E.name == "__meta__") {
- if (pinned_props.size()) {
- Dictionary meta_override;
- meta_override["_edit_pinned_properties_"] = pinned_props;
- forced_value = meta_override;
- }
- }
}
StringName name = E.name;
- Variant value = forced_value.get_type() == Variant::NIL ? p_node->get(name) : forced_value;
+ Variant value = p_node->get(name);
if (E.type == Variant::OBJECT && missing_resource_properties.has(E.name)) {
// Was this missing resource overriden? If so do not save the old value.
@@ -557,7 +544,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
}
}
- if (!pinned_props.has(name) && forced_value.get_type() == Variant::NIL) {
+ if (!pinned_props.has(name)) {
bool is_valid_default = false;
Variant default_value = PropertyUtils::get_property_default_value(p_node, name, &is_valid_default, &states_stack, true);
if (is_valid_default && !PropertyUtils::is_property_value_different(value, default_value)) {