summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/debugger/engine_debugger.cpp2
-rw-r--r--core/extension/extension_api_dump.cpp2
-rw-r--r--core/io/ip_address.cpp2
-rw-r--r--core/object/object.cpp7
-rw-r--r--core/string/ustring.cpp2
-rw-r--r--core/string/ustring.h2
-rw-r--r--core/templates/command_queue_mt.h15
-rw-r--r--core/variant/variant_call.cpp1
8 files changed, 25 insertions, 8 deletions
diff --git a/core/debugger/engine_debugger.cpp b/core/debugger/engine_debugger.cpp
index a7655c874a..97a020e4c3 100644
--- a/core/debugger/engine_debugger.cpp
+++ b/core/debugger/engine_debugger.cpp
@@ -137,7 +137,7 @@ void EngineDebugger::initialize(const String &p_uri, bool p_skip_breakpoints, co
script_debugger = memnew(ScriptDebugger);
// Tell the OS that we want to handle termination signals.
OS::get_singleton()->initialize_debugging();
- } else if (p_uri.find("://") >= 0) {
+ } else if (p_uri.contains("://")) {
const String proto = p_uri.substr(0, p_uri.find("://") + 3);
if (!protocols.has(proto)) {
return;
diff --git a/core/extension/extension_api_dump.cpp b/core/extension/extension_api_dump.cpp
index 1c9b4dc3e8..848b6f3886 100644
--- a/core/extension/extension_api_dump.cpp
+++ b/core/extension/extension_api_dump.cpp
@@ -1201,7 +1201,7 @@ Dictionary GDExtensionAPIDump::generate_extension_api(bool p_include_docs) {
if (F.name.begins_with("_")) {
continue; //hidden property
}
- if (F.name.find("/") >= 0) {
+ if (F.name.contains("/")) {
// Ignore properties with '/' (slash) in the name. These are only meant for use in the inspector.
continue;
}
diff --git a/core/io/ip_address.cpp b/core/io/ip_address.cpp
index ce74bb36d6..a93876a2b5 100644
--- a/core/io/ip_address.cpp
+++ b/core/io/ip_address.cpp
@@ -202,7 +202,7 @@ IPAddress::IPAddress(const String &p_string) {
// Wildcard (not a valid IP)
wildcard = true;
- } else if (p_string.find(":") >= 0) {
+ } else if (p_string.contains(":")) {
// IPv6
_parse_ipv6(p_string);
valid = true;
diff --git a/core/object/object.cpp b/core/object/object.cpp
index ab89f96a0d..dfc8e2a29a 100644
--- a/core/object/object.cpp
+++ b/core/object/object.cpp
@@ -2307,9 +2307,9 @@ void ObjectDB::setup() {
}
void ObjectDB::cleanup() {
- if (slot_count > 0) {
- spin_lock.lock();
+ spin_lock.lock();
+ if (slot_count > 0) {
WARN_PRINT("ObjectDB instances leaked at exit (run with --verbose for details).");
if (OS::get_singleton()->is_stdout_verbose()) {
// Ensure calling the native classes because if a leaked instance has a script
@@ -2340,10 +2340,11 @@ void ObjectDB::cleanup() {
}
print_line("Hint: Leaked instances typically happen when nodes are removed from the scene tree (with `remove_child()`) but not freed (with `free()` or `queue_free()`).");
}
- spin_lock.unlock();
}
if (object_slots) {
memfree(object_slots);
}
+
+ spin_lock.unlock();
}
diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp
index 7cd1a39d38..3d37e17ef8 100644
--- a/core/string/ustring.cpp
+++ b/core/string/ustring.cpp
@@ -3964,7 +3964,7 @@ String String::format(const Variant &values, const String &placeholder) const {
Variant v_val = values_arr[i];
String val = v_val;
- if (placeholder.find("_") > -1) {
+ if (placeholder.contains("_")) {
new_string = new_string.replace(placeholder.replace("_", i_as_str), val);
} else {
new_string = new_string.replace_first(placeholder, val);
diff --git a/core/string/ustring.h b/core/string/ustring.h
index a020c7d372..9df2d56e80 100644
--- a/core/string/ustring.h
+++ b/core/string/ustring.h
@@ -429,6 +429,8 @@ public:
_FORCE_INLINE_ bool is_empty() const { return length() == 0; }
_FORCE_INLINE_ bool contains(const char *p_str) const { return find(p_str) != -1; }
_FORCE_INLINE_ bool contains(const String &p_str) const { return find(p_str) != -1; }
+ _FORCE_INLINE_ bool containsn(const char *p_str) const { return findn(p_str) != -1; }
+ _FORCE_INLINE_ bool containsn(const String &p_str) const { return findn(p_str) != -1; }
// path functions
bool is_absolute_path() const;
diff --git a/core/templates/command_queue_mt.h b/core/templates/command_queue_mt.h
index d14465d216..dbf938a117 100644
--- a/core/templates/command_queue_mt.h
+++ b/core/templates/command_queue_mt.h
@@ -302,7 +302,7 @@ class CommandQueueMT {
struct CommandBase {
bool sync = false;
virtual void call() = 0;
- virtual ~CommandBase() = default; // Won't be called.
+ virtual ~CommandBase() = default;
};
struct SyncCommand : public CommandBase {
@@ -379,6 +379,10 @@ class CommandQueueMT {
lock();
}
+ // If the command involved reallocating the buffer, the address may have changed.
+ cmd = reinterpret_cast<CommandBase *>(&command_mem[flush_read_ptr]);
+ cmd->~CommandBase();
+
flush_read_ptr += size;
}
WorkerThreadPool::thread_exit_command_queue_mt_flush();
@@ -401,6 +405,8 @@ class CommandQueueMT {
_prevent_sync_wraparound();
}
+ void _no_op() {}
+
public:
void lock();
void unlock();
@@ -422,10 +428,15 @@ public:
_flush();
}
}
+
void flush_all() {
_flush();
}
+ void sync() {
+ push_and_sync(this, &CommandQueueMT::_no_op);
+ }
+
void wait_and_flush() {
ERR_FAIL_COND(pump_task_id == WorkerThreadPool::INVALID_TASK_ID);
WorkerThreadPool::get_singleton()->wait_for_task_completion(pump_task_id);
@@ -433,7 +444,9 @@ public:
}
void set_pump_task_id(WorkerThreadPool::TaskID p_task_id) {
+ lock();
pump_task_id = p_task_id;
+ unlock();
}
CommandQueueMT();
diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp
index c5861f3fbb..9b7777f480 100644
--- a/core/variant/variant_call.cpp
+++ b/core/variant/variant_call.cpp
@@ -1707,6 +1707,7 @@ static void _register_variant_builtin_methods() {
bind_string_method(sha256_buffer, sarray(), varray());
bind_string_method(is_empty, sarray(), varray());
bind_string_methodv(contains, static_cast<bool (String::*)(const String &) const>(&String::contains), sarray("what"), varray());
+ bind_string_methodv(containsn, static_cast<bool (String::*)(const String &) const>(&String::containsn), sarray("what"), varray());
bind_string_method(is_absolute_path, sarray(), varray());
bind_string_method(is_relative_path, sarray(), varray());