mirror of https://github.com/godotengine/godot
Merge pull request #72703 from lyuma/stringname_constructor_mistake
StringName: fix returning dangling data from char constructor.
This commit is contained in:
commit
112f8faf5c
|
|
@ -226,19 +226,16 @@ StringName::StringName(const char *p_name, bool p_static) {
|
||||||
_data = _data->next;
|
_data = _data->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_data) {
|
if (_data && _data->refcount.ref()) {
|
||||||
if (_data->refcount.ref()) {
|
// exists
|
||||||
// exists
|
if (p_static) {
|
||||||
if (p_static) {
|
_data->static_count.increment();
|
||||||
_data->static_count.increment();
|
|
||||||
}
|
|
||||||
#ifdef DEBUG_ENABLED
|
|
||||||
if (unlikely(debug_stringname)) {
|
|
||||||
_data->debug_references++;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
|
if (unlikely(debug_stringname)) {
|
||||||
|
_data->debug_references++;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -288,19 +285,17 @@ StringName::StringName(const StaticCString &p_static_string, bool p_static) {
|
||||||
_data = _data->next;
|
_data = _data->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_data) {
|
if (_data && _data->refcount.ref()) {
|
||||||
if (_data->refcount.ref()) {
|
// exists
|
||||||
// exists
|
if (p_static) {
|
||||||
if (p_static) {
|
_data->static_count.increment();
|
||||||
_data->static_count.increment();
|
|
||||||
}
|
|
||||||
#ifdef DEBUG_ENABLED
|
|
||||||
if (unlikely(debug_stringname)) {
|
|
||||||
_data->debug_references++;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
|
if (unlikely(debug_stringname)) {
|
||||||
|
_data->debug_references++;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_data = memnew(_Data);
|
_data = memnew(_Data);
|
||||||
|
|
@ -348,19 +343,17 @@ StringName::StringName(const String &p_name, bool p_static) {
|
||||||
_data = _data->next;
|
_data = _data->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_data) {
|
if (_data && _data->refcount.ref()) {
|
||||||
if (_data->refcount.ref()) {
|
// exists
|
||||||
// exists
|
if (p_static) {
|
||||||
if (p_static) {
|
_data->static_count.increment();
|
||||||
_data->static_count.increment();
|
|
||||||
}
|
|
||||||
#ifdef DEBUG_ENABLED
|
|
||||||
if (unlikely(debug_stringname)) {
|
|
||||||
_data->debug_references++;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
|
if (unlikely(debug_stringname)) {
|
||||||
|
_data->debug_references++;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_data = memnew(_Data);
|
_data = memnew(_Data);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue