summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/io/file_access_pack.cpp9
-rw-r--r--core/io/ip.cpp65
-rw-r--r--core/message_queue.cpp10
-rw-r--r--core/os/input_event.h6
4 files changed, 62 insertions, 28 deletions
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp
index bb942b54d7..79aa39521f 100644
--- a/core/io/file_access_pack.cpp
+++ b/core/io/file_access_pack.cpp
@@ -440,13 +440,12 @@ Error DirAccessPack::change_dir(String p_dir) {
String DirAccessPack::get_current_dir() {
- String p;
PackedData::PackedDir *pd = current;
- while (pd->parent) {
+ String p = current->name;
- if (pd != current)
- p = "/" + p;
- p = p + pd->name;
+ while (pd->parent) {
+ pd = pd->parent;
+ p = pd->name + "/" + p;
}
return "res://" + p;
diff --git a/core/io/ip.cpp b/core/io/ip.cpp
index bf139eeacb..6c463b983c 100644
--- a/core/io/ip.cpp
+++ b/core/io/ip.cpp
@@ -68,6 +68,7 @@ struct _IP_ResolverPrivate {
return IP::RESOLVER_INVALID_ID;
}
+ Mutex *mutex;
Semaphore *sem;
Thread *thread;
@@ -96,8 +97,10 @@ struct _IP_ResolverPrivate {
while (!ipr->thread_abort) {
ipr->sem->wait();
- GLOBAL_LOCK_FUNCTION;
+
+ ipr->mutex->lock();
ipr->resolve_queues();
+ ipr->mutex->unlock();
}
}
@@ -110,24 +113,30 @@ struct _IP_ResolverPrivate {
IP_Address IP::resolve_hostname(const String &p_hostname, IP::Type p_type) {
- GLOBAL_LOCK_FUNCTION;
+ resolver->mutex->lock();
String key = _IP_ResolverPrivate::get_cache_key(p_hostname, p_type);
- if (resolver->cache.has(key))
- return resolver->cache[key];
+ if (resolver->cache.has(key)) {
+ IP_Address res = resolver->cache[key];
+ resolver->mutex->unlock();
+ return res;
+ }
IP_Address res = _resolve_hostname(p_hostname, p_type);
resolver->cache[key] = res;
+ resolver->mutex->unlock();
return res;
}
+
IP::ResolverID IP::resolve_hostname_queue_item(const String &p_hostname, IP::Type p_type) {
- GLOBAL_LOCK_FUNCTION;
+ resolver->mutex->lock();
ResolverID id = resolver->find_empty_id();
if (id == RESOLVER_INVALID_ID) {
WARN_PRINT("Out of resolver queries");
+ resolver->mutex->unlock();
return id;
}
@@ -146,6 +155,7 @@ IP::ResolverID IP::resolve_hostname_queue_item(const String &p_hostname, IP::Typ
resolver->resolve_queues();
}
+ resolver->mutex->unlock();
return id;
}
@@ -153,35 +163,51 @@ IP::ResolverStatus IP::get_resolve_item_status(ResolverID p_id) const {
ERR_FAIL_INDEX_V(p_id, IP::RESOLVER_MAX_QUERIES, IP::RESOLVER_STATUS_NONE);
- GLOBAL_LOCK_FUNCTION;
- ERR_FAIL_COND_V(resolver->queue[p_id].status == IP::RESOLVER_STATUS_NONE, IP::RESOLVER_STATUS_NONE);
+ resolver->mutex->lock();
+ if (resolver->queue[p_id].status == IP::RESOLVER_STATUS_NONE) {
+ ERR_PRINT("Condition status == IP::RESOLVER_STATUS_NONE");
+ resolver->mutex->unlock();
+ return IP::RESOLVER_STATUS_NONE;
+ }
+ IP::ResolverStatus res = resolver->queue[p_id].status;
- return resolver->queue[p_id].status;
+ resolver->mutex->unlock();
+ return res;
}
+
IP_Address IP::get_resolve_item_address(ResolverID p_id) const {
ERR_FAIL_INDEX_V(p_id, IP::RESOLVER_MAX_QUERIES, IP_Address());
- GLOBAL_LOCK_FUNCTION;
+ resolver->mutex->lock();
if (resolver->queue[p_id].status != IP::RESOLVER_STATUS_DONE) {
- ERR_EXPLAIN("Resolve of '" + resolver->queue[p_id].hostname + "'' didn't complete yet.");
- ERR_FAIL_COND_V(resolver->queue[p_id].status != IP::RESOLVER_STATUS_DONE, IP_Address());
+ ERR_PRINTS("Resolve of '" + resolver->queue[p_id].hostname + "'' didn't complete yet.");
+ resolver->mutex->unlock();
+ return IP_Address();
}
- return resolver->queue[p_id].response;
+ IP_Address res = resolver->queue[p_id].response;
+
+ resolver->mutex->unlock();
+ return res;
}
+
void IP::erase_resolve_item(ResolverID p_id) {
ERR_FAIL_INDEX(p_id, IP::RESOLVER_MAX_QUERIES);
- GLOBAL_LOCK_FUNCTION;
+ resolver->mutex->lock();
resolver->queue[p_id].status = IP::RESOLVER_STATUS_NONE;
+
+ resolver->mutex->unlock();
}
void IP::clear_cache(const String &p_hostname) {
+ resolver->mutex->lock();
+
if (p_hostname.empty()) {
resolver->cache.clear();
} else {
@@ -190,7 +216,9 @@ void IP::clear_cache(const String &p_hostname) {
resolver->cache.erase(_IP_ResolverPrivate::get_cache_key(p_hostname, IP::TYPE_IPV6));
resolver->cache.erase(_IP_ResolverPrivate::get_cache_key(p_hostname, IP::TYPE_ANY));
}
-};
+
+ resolver->mutex->unlock();
+}
Array IP::_get_local_addresses() const {
@@ -249,12 +277,11 @@ IP::IP() {
singleton = this;
resolver = memnew(_IP_ResolverPrivate);
resolver->sem = NULL;
+ resolver->mutex = Mutex::create();
#ifndef NO_THREADS
- //resolver->sem = Semaphore::create();
-
- resolver->sem = NULL;
+ resolver->sem = Semaphore::create();
if (resolver->sem) {
resolver->thread_abort = false;
@@ -281,7 +308,9 @@ IP::~IP() {
memdelete(resolver->thread);
memdelete(resolver->sem);
}
- memdelete(resolver);
#endif
+
+ memdelete(resolver->mutex);
+ memdelete(resolver);
}
diff --git a/core/message_queue.cpp b/core/message_queue.cpp
index 14e8913d9f..fa1c8112cc 100644
--- a/core/message_queue.cpp
+++ b/core/message_queue.cpp
@@ -51,9 +51,10 @@ Error MessageQueue::push_call(ObjectID p_id, const StringName &p_method, const V
type = ObjectDB::get_instance(p_id)->get_class();
print_line("failed method: " + type + ":" + p_method + " target ID: " + itos(p_id));
statistics();
+ ERR_EXPLAIN("Message queue out of memory. Try increasing 'message_queue_size_kb' in project settings");
+ ERR_FAIL_V(ERR_OUT_OF_MEMORY);
}
- ERR_FAIL_COND_V((buffer_end + room_needed) >= buffer_size, ERR_OUT_OF_MEMORY);
Message *msg = memnew_placement(&buffer[buffer_end], Message);
msg->args = p_argcount;
msg->instance_ID = p_id;
@@ -101,10 +102,10 @@ Error MessageQueue::push_set(ObjectID p_id, const StringName &p_prop, const Vari
type = ObjectDB::get_instance(p_id)->get_class();
print_line("failed set: " + type + ":" + p_prop + " target ID: " + itos(p_id));
statistics();
+ ERR_EXPLAIN("Message queue out of memory. Try increasing 'message_queue_size_kb' in project settings");
+ ERR_FAIL_V(ERR_OUT_OF_MEMORY);
}
- ERR_FAIL_COND_V((buffer_end + room_needed) >= buffer_size, ERR_OUT_OF_MEMORY);
-
Message *msg = memnew_placement(&buffer[buffer_end], Message);
msg->args = 1;
msg->instance_ID = p_id;
@@ -134,9 +135,10 @@ Error MessageQueue::push_notification(ObjectID p_id, int p_notification) {
type = ObjectDB::get_instance(p_id)->get_class();
print_line("failed notification: " + itos(p_notification) + " target ID: " + itos(p_id));
statistics();
+ ERR_EXPLAIN("Message queue out of memory. Try increasing 'message_queue_size_kb' in project settings");
+ ERR_FAIL_V(ERR_OUT_OF_MEMORY);
}
- ERR_FAIL_COND_V((buffer_end + room_needed) >= buffer_size, ERR_OUT_OF_MEMORY);
Message *msg = memnew_placement(&buffer[buffer_end], Message);
msg->type = TYPE_NOTIFICATION;
diff --git a/core/os/input_event.h b/core/os/input_event.h
index eb5c5685e5..93cceac27c 100644
--- a/core/os/input_event.h
+++ b/core/os/input_event.h
@@ -188,6 +188,7 @@ struct InputEventMouse {
struct InputEventMouseButton : public InputEventMouse {
+ double factor;
int button_index;
bool pressed; //otherwise released
bool doubleclick; //last even less than doubleclick time
@@ -272,7 +273,10 @@ struct InputEvent {
InputEvent xform_by(const Transform2D &p_xform) const;
bool operator==(const InputEvent &p_event) const;
operator String() const;
- InputEvent() { zeromem(this, sizeof(InputEvent)); }
+ InputEvent() {
+ zeromem(this, sizeof(InputEvent));
+ mouse_button.factor = 1;
+ }
};
#endif