diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/image.cpp | 7 | ||||
-rw-r--r-- | core/io/resource_import.cpp | 36 | ||||
-rw-r--r-- | core/io/resource_import.h | 4 | ||||
-rw-r--r-- | core/script_debugger_remote.cpp | 43 | ||||
-rw-r--r-- | core/script_debugger_remote.h | 4 | ||||
-rw-r--r-- | core/undo_redo.cpp | 6 | ||||
-rw-r--r-- | core/variant_op.cpp | 8 |
7 files changed, 77 insertions, 31 deletions
diff --git a/core/image.cpp b/core/image.cpp index 59d66fd66a..41d70e6df6 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -447,8 +447,6 @@ void Image::convert(Format p_new_format) { Image new_img(width, height, 0, p_new_format); - //int len=data.size(); - PoolVector<uint8_t>::Read r = data.read(); PoolVector<uint8_t>::Write w = new_img.data.write(); @@ -696,6 +694,11 @@ void Image::resize_to_po2(bool p_square) { void Image::resize(int p_width, int p_height, Interpolation p_interpolation) { + if (data.size() == 0) { + ERR_EXPLAIN("Cannot resize image before creating it, use create() or create_from_data() first."); + ERR_FAIL(); + } + if (!_can_modify(format)) { ERR_EXPLAIN("Cannot resize in indexed, compressed or custom image formats."); ERR_FAIL(); diff --git a/core/io/resource_import.cpp b/core/io/resource_import.cpp index 58de944e6c..cfe6655504 100644 --- a/core/io/resource_import.cpp +++ b/core/io/resource_import.cpp @@ -138,9 +138,9 @@ void ResourceFormatImporter::get_recognized_extensions(List<String> *p_extension Set<String> found; - for (Set<Ref<ResourceImporter> >::Element *E = importers.front(); E; E = E->next()) { + for (int i = 0; i < importers.size(); i++) { List<String> local_exts; - E->get()->get_recognized_extensions(&local_exts); + importers[i]->get_recognized_extensions(&local_exts); for (List<String>::Element *F = local_exts.front(); F; F = F->next()) { if (!found.has(F->get())) { p_extensions->push_back(F->get()); @@ -158,8 +158,8 @@ void ResourceFormatImporter::get_recognized_extensions_for_type(const String &p_ Set<String> found; - for (Set<Ref<ResourceImporter> >::Element *E = importers.front(); E; E = E->next()) { - String res_type = E->get()->get_resource_type(); + for (int i = 0; i < importers.size(); i++) { + String res_type = importers[i]->get_resource_type(); if (res_type == String()) continue; @@ -167,7 +167,7 @@ void ResourceFormatImporter::get_recognized_extensions_for_type(const String &p_ continue; List<String> local_exts; - E->get()->get_recognized_extensions(&local_exts); + importers[i]->get_recognized_extensions(&local_exts); for (List<String>::Element *F = local_exts.front(); F; F = F->next()) { if (!found.has(F->get())) { p_extensions->push_back(F->get()); @@ -212,9 +212,9 @@ int ResourceFormatImporter::get_import_order(const String &p_path) const { bool ResourceFormatImporter::handles_type(const String &p_type) const { - for (Set<Ref<ResourceImporter> >::Element *E = importers.front(); E; E = E->next()) { + for (int i = 0; i < importers.size(); i++) { - String res_type = E->get()->get_resource_type(); + String res_type = importers[i]->get_resource_type(); if (res_type == String()) continue; if (ClassDB::is_parent_class(res_type, p_type)) @@ -319,9 +319,9 @@ void ResourceFormatImporter::get_dependencies(const String &p_path, List<String> Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_name(const String &p_name) const { - for (Set<Ref<ResourceImporter> >::Element *E = importers.front(); E; E = E->next()) { - if (E->get()->get_importer_name() == p_name) { - return E->get(); + for (int i = 0; i < importers.size(); i++) { + if (importers[i]->get_importer_name() == p_name) { + return importers[i]; } } @@ -330,12 +330,12 @@ Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_name(const String void ResourceFormatImporter::get_importers_for_extension(const String &p_extension, List<Ref<ResourceImporter> > *r_importers) { - for (Set<Ref<ResourceImporter> >::Element *E = importers.front(); E; E = E->next()) { + for (int i = 0; i < importers.size(); i++) { List<String> local_exts; - E->get()->get_recognized_extensions(&local_exts); + importers[i]->get_recognized_extensions(&local_exts); for (List<String>::Element *F = local_exts.front(); F; F = F->next()) { if (p_extension.to_lower() == F->get()) { - r_importers->push_back(E->get()); + r_importers->push_back(importers[i]); } } } @@ -346,14 +346,14 @@ Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_extension(const St Ref<ResourceImporter> importer; float priority = 0; - for (Set<Ref<ResourceImporter> >::Element *E = importers.front(); E; E = E->next()) { + for (int i = 0; i < importers.size(); i++) { List<String> local_exts; - E->get()->get_recognized_extensions(&local_exts); + importers[i]->get_recognized_extensions(&local_exts); for (List<String>::Element *F = local_exts.front(); F; F = F->next()) { - if (p_extension.to_lower() == F->get() && E->get()->get_priority() > priority) { - importer = E->get(); - priority = E->get()->get_priority(); + if (p_extension.to_lower() == F->get() && importers[i]->get_priority() > priority) { + importer = importers[i]; + priority = importers[i]->get_priority(); } } } diff --git a/core/io/resource_import.h b/core/io/resource_import.h index 1b681bd97a..80e0743eda 100644 --- a/core/io/resource_import.h +++ b/core/io/resource_import.h @@ -46,7 +46,7 @@ class ResourceFormatImporter : public ResourceFormatLoader { static ResourceFormatImporter *singleton; - Set<Ref<ResourceImporter> > importers; + Vector<Ref<ResourceImporter> > importers; public: static ResourceFormatImporter *get_singleton() { return singleton; } @@ -65,7 +65,7 @@ public: String get_internal_resource_path(const String &p_path) const; void get_internal_resource_path_list(const String &p_path, List<String> *r_paths); - void add_importer(const Ref<ResourceImporter> &p_importer) { importers.insert(p_importer); } + void add_importer(const Ref<ResourceImporter> &p_importer) { importers.push_back(p_importer); } void remove_importer(const Ref<ResourceImporter> &p_importer) { importers.erase(p_importer); } Ref<ResourceImporter> get_importer_by_name(const String &p_name) const; Ref<ResourceImporter> get_importer_by_extension(const String &p_extension) const; diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index bbc2125c5a..e3dc8eb53a 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -355,6 +355,13 @@ void ScriptDebuggerRemote::_get_output() { locking = false; } + if (n_messages_dropped > 0) { + Message msg; + msg.message = "Too many messages! " + String::num_int64(n_messages_dropped) + " messages were dropped."; + messages.push_back(msg); + n_messages_dropped = 0; + } + while (messages.size()) { locking = true; packet_peer_stream->put_var("message:" + messages.front()->get().message); @@ -366,6 +373,20 @@ void ScriptDebuggerRemote::_get_output() { locking = false; } + if (n_errors_dropped > 0) { + OutputError oe; + oe.error = "TOO_MANY_ERRORS"; + oe.error_descr = "Too many errors! " + String::num_int64(n_errors_dropped) + " errors were dropped."; + oe.warning = false; + uint64_t time = OS::get_singleton()->get_ticks_msec(); + oe.hr = time / 3600000; + oe.min = (time / 60000) % 60; + oe.sec = (time / 1000) % 60; + oe.msec = time % 1000; + errors.push_back(oe); + n_errors_dropped = 0; + } + while (errors.size()) { locking = true; packet_peer_stream->put_var("error"); @@ -453,7 +474,11 @@ void ScriptDebuggerRemote::_err_handler(void *ud, const char *p_func, const char if (!sdr->locking && sdr->tcp_client->is_connected_to_host()) { - sdr->errors.push_back(oe); + if (sdr->errors.size() >= sdr->max_errors_per_frame) { + sdr->n_errors_dropped++; + } else { + sdr->errors.push_back(oe); + } } sdr->mutex->unlock(); @@ -891,10 +916,14 @@ void ScriptDebuggerRemote::send_message(const String &p_message, const Array &p_ mutex->lock(); if (!locking && tcp_client->is_connected_to_host()) { - Message msg; - msg.message = p_message; - msg.data = p_args; - messages.push_back(msg); + if (messages.size() >= max_messages_per_frame) { + n_messages_dropped++; + } else { + Message msg; + msg.message = p_message; + msg.data = p_args; + messages.push_back(msg); + } } mutex->unlock(); } @@ -1011,7 +1040,11 @@ ScriptDebuggerRemote::ScriptDebuggerRemote() : requested_quit(false), mutex(Mutex::create()), max_cps(GLOBAL_GET("network/limits/debugger_stdout/max_chars_per_second")), + max_messages_per_frame(GLOBAL_GET("network/limits/debugger_stdout/max_messages_per_frame")), + max_errors_per_frame(GLOBAL_GET("network/limits/debugger_stdout/max_errors_per_frame")), char_count(0), + n_messages_dropped(0), + n_errors_dropped(0), last_msec(0), msec_count(0), locking(false), diff --git a/core/script_debugger_remote.h b/core/script_debugger_remote.h index 00ed22dc29..924d5de2c4 100644 --- a/core/script_debugger_remote.h +++ b/core/script_debugger_remote.h @@ -87,7 +87,11 @@ class ScriptDebuggerRemote : public ScriptDebugger { List<String> output_strings; List<Message> messages; + int max_messages_per_frame; + int n_messages_dropped; List<OutputError> errors; + int max_errors_per_frame; + int n_errors_dropped; int max_cps; int char_count; diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp index a8eb527b09..a105fba290 100644 --- a/core/undo_redo.cpp +++ b/core/undo_redo.cpp @@ -108,6 +108,7 @@ void UndoRedo::create_action(const String &p_name, MergeMode p_mode) { void UndoRedo::add_do_method(Object *p_object, const String &p_method, VARIANT_ARG_DECLARE) { VARIANT_ARGPTRS + ERR_FAIL_COND(p_object == NULL); ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); Operation do_op; @@ -127,6 +128,7 @@ void UndoRedo::add_do_method(Object *p_object, const String &p_method, VARIANT_A void UndoRedo::add_undo_method(Object *p_object, const String &p_method, VARIANT_ARG_DECLARE) { VARIANT_ARGPTRS + ERR_FAIL_COND(p_object == NULL); ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); @@ -149,6 +151,7 @@ void UndoRedo::add_undo_method(Object *p_object, const String &p_method, VARIANT } void UndoRedo::add_do_property(Object *p_object, const String &p_property, const Variant &p_value) { + ERR_FAIL_COND(p_object == NULL); ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); Operation do_op; @@ -163,6 +166,7 @@ void UndoRedo::add_do_property(Object *p_object, const String &p_property, const } void UndoRedo::add_undo_property(Object *p_object, const String &p_property, const Variant &p_value) { + ERR_FAIL_COND(p_object == NULL); ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); @@ -182,6 +186,7 @@ void UndoRedo::add_undo_property(Object *p_object, const String &p_property, con } void UndoRedo::add_do_reference(Object *p_object) { + ERR_FAIL_COND(p_object == NULL); ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); Operation do_op; @@ -194,6 +199,7 @@ void UndoRedo::add_do_reference(Object *p_object) { } void UndoRedo::add_undo_reference(Object *p_object) { + ERR_FAIL_COND(p_object == NULL); ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 662371b107..e46fac77ee 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -339,7 +339,7 @@ bool Variant::booleanize() const { CASE_TYPE(m_prefix, m_op_name, m_name) { \ if (p_b.type == NIL) \ _RETURN(true) \ - DEFAULT_OP_ARRAY_OP_BODY(m_prefix, m_op_name, m_name, m_type, !=, ==, true, true, false) \ + DEFAULT_OP_ARRAY_OP_BODY(m_prefix, m_op_name, m_name, m_type, !=, !=, false, true, true) \ } #define DEFAULT_OP_ARRAY_LT(m_prefix, m_op_name, m_name, m_type) \ @@ -539,12 +539,12 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, if (arr_b->size() != l) _RETURN(true); for (int i = 0; i < l; i++) { - if (((*arr_a)[i] == (*arr_b)[i])) { - _RETURN(false); + if (((*arr_a)[i] != (*arr_b)[i])) { + _RETURN(true); } } - _RETURN(true); + _RETURN(false); } DEFAULT_OP_NUM_NULL(math, OP_NOT_EQUAL, INT, !=, _int); |