diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/core_bind.cpp | 6 | ||||
-rw-r--r-- | core/core_bind.h | 2 | ||||
-rw-r--r-- | core/object/undo_redo.cpp | 20 | ||||
-rw-r--r-- | core/os/os.cpp | 4 | ||||
-rw-r--r-- | core/os/os.h | 2 |
5 files changed, 28 insertions, 6 deletions
diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 9a58528bd7..8ec934db62 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -196,6 +196,10 @@ int _OS::get_low_processor_usage_mode_sleep_usec() const { return OS::get_singleton()->get_low_processor_usage_mode_sleep_usec(); } +void _OS::alert(const String &p_alert, const String &p_title) { + OS::get_singleton()->alert(p_alert, p_title); +} + String _OS::get_executable_path() const { return OS::get_singleton()->get_executable_path(); } @@ -487,6 +491,8 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("open_midi_inputs"), &_OS::open_midi_inputs); ClassDB::bind_method(D_METHOD("close_midi_inputs"), &_OS::close_midi_inputs); + ClassDB::bind_method(D_METHOD("alert", "text", "title"), &_OS::alert, DEFVAL("Alert!")); + ClassDB::bind_method(D_METHOD("set_low_processor_usage_mode", "enable"), &_OS::set_low_processor_usage_mode); ClassDB::bind_method(D_METHOD("is_in_low_processor_usage_mode"), &_OS::is_in_low_processor_usage_mode); diff --git a/core/core_bind.h b/core/core_bind.h index 673dbe32c4..43f74dc9bd 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -162,6 +162,8 @@ public: void set_low_processor_usage_mode_sleep_usec(int p_usec); int get_low_processor_usage_mode_sleep_usec() const; + void alert(const String &p_alert, const String &p_title = "ALERT!"); + String get_executable_path() const; int execute(const String &p_path, const Vector<String> &p_arguments, Array r_output = Array(), bool p_read_stderr = false); int create_process(const String &p_path, const Vector<String> &p_arguments); diff --git a/core/object/undo_redo.cpp b/core/object/undo_redo.cpp index 0532b2ae40..6808d7602d 100644 --- a/core/object/undo_redo.cpp +++ b/core/object/undo_redo.cpp @@ -41,9 +41,13 @@ void UndoRedo::_discard_redo() { for (int i = current_action + 1; i < actions.size(); i++) { for (List<Operation>::Element *E = actions.write[i].do_ops.front(); E; E = E->next()) { if (E->get().type == Operation::TYPE_REFERENCE) { - Object *obj = ObjectDB::get_instance(E->get().object); - if (obj) { - memdelete(obj); + if (E->get().ref.is_valid()) { + E->get().ref.unref(); + } else { + Object *obj = ObjectDB::get_instance(E->get().object); + if (obj) { + memdelete(obj); + } } } } @@ -242,9 +246,13 @@ void UndoRedo::_pop_history_tail() { for (List<Operation>::Element *E = actions.write[0].undo_ops.front(); E; E = E->next()) { if (E->get().type == Operation::TYPE_REFERENCE) { - Object *obj = ObjectDB::get_instance(E->get().object); - if (obj) { - memdelete(obj); + if (E->get().ref.is_valid()) { + E->get().ref.unref(); + } else { + Object *obj = ObjectDB::get_instance(E->get().object); + if (obj) { + memdelete(obj); + } } } } diff --git a/core/os/os.cpp b/core/os/os.cpp index 535eee4797..f7af74da3e 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -110,6 +110,10 @@ void OS::printerr(const char *p_format, ...) { va_end(argp); } +void OS::alert(const String &p_alert, const String &p_title) { + fprintf(stderr, "%s: %s\n", p_title.utf8().get_data(), p_alert.utf8().get_data()); +} + void OS::set_low_processor_usage_mode(bool p_enabled) { low_processor_usage_mode = p_enabled; } diff --git a/core/os/os.h b/core/os/os.h index 301718a8b3..fcb195afe1 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -120,6 +120,8 @@ public: virtual void open_midi_inputs(); virtual void close_midi_inputs(); + virtual void alert(const String &p_alert, const String &p_title = "ALERT!"); + virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false) { return ERR_UNAVAILABLE; } virtual Error close_dynamic_library(void *p_library_handle) { return ERR_UNAVAILABLE; } virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false) { return ERR_UNAVAILABLE; } |