Removed the InputEvent ID field, which was unused and can cause bugs.

This commit is contained in:
Juan Linietsky 2017-12-26 09:48:50 -03:00
parent 37aab45091
commit 4a2eef4ad8
8 changed files with 13 additions and 44 deletions

View file

@ -32,14 +32,6 @@
#include "input_map.h"
#include "os/keyboard.h"
void InputEvent::set_id(uint32_t p_id) {
id = p_id;
}
uint32_t InputEvent::get_id() const {
return id;
}
void InputEvent::set_device(int p_device) {
device = p_device;
}
@ -99,9 +91,6 @@ bool InputEvent::is_action_type() const {
void InputEvent::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_id", "id"), &InputEvent::set_id);
ClassDB::bind_method(D_METHOD("get_id"), &InputEvent::get_id);
ClassDB::bind_method(D_METHOD("set_device", "device"), &InputEvent::set_device);
ClassDB::bind_method(D_METHOD("get_device"), &InputEvent::get_device);
@ -125,7 +114,6 @@ void InputEvent::_bind_methods() {
InputEvent::InputEvent() {
id = 0;
device = 0;
}
@ -441,7 +429,6 @@ Ref<InputEvent> InputEventMouseButton::xformed_by(const Transform2D &p_xform, co
Ref<InputEventMouseButton> mb;
mb.instance();
mb->set_id(get_id());
mb->set_device(get_device());
mb->set_modifiers_from_event(this);
@ -557,7 +544,6 @@ Ref<InputEvent> InputEventMouseMotion::xformed_by(const Transform2D &p_xform, co
Ref<InputEventMouseMotion> mm;
mm.instance();
mm->set_id(get_id());
mm->set_device(get_device());
mm->set_modifiers_from_event(this);
@ -764,7 +750,6 @@ Ref<InputEvent> InputEventScreenTouch::xformed_by(const Transform2D &p_xform, co
Ref<InputEventScreenTouch> st;
st.instance();
st->set_id(get_id());
st->set_device(get_device());
st->set_index(index);
st->set_position(p_xform.xform(pos + p_local_ofs));
@ -845,7 +830,6 @@ Ref<InputEvent> InputEventScreenDrag::xformed_by(const Transform2D &p_xform, con
sd.instance();
sd->set_id(get_id());
sd->set_device(get_device());
sd->set_index(index);
@ -968,7 +952,6 @@ Ref<InputEvent> InputEventMagnifyGesture::xformed_by(const Transform2D &p_xform,
Ref<InputEventMagnifyGesture> ev;
ev.instance();
ev->set_id(get_id());
ev->set_device(get_device());
ev->set_modifiers_from_event(this);
@ -1006,7 +989,6 @@ Ref<InputEvent> InputEventPanGesture::xformed_by(const Transform2D &p_xform, con
Ref<InputEventPanGesture> ev;
ev.instance();
ev->set_id(get_id());
ev->set_device(get_device());
ev->set_modifiers_from_event(this);

View file

@ -144,16 +144,12 @@ enum JoystickList {
class InputEvent : public Resource {
GDCLASS(InputEvent, Resource)
uint32_t id;
int device;
protected:
static void _bind_methods();
public:
void set_id(uint32_t p_id);
uint32_t get_id() const;
void set_device(int p_device);
int get_device() const;

View file

@ -1775,7 +1775,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
case TreeItem::CELL_MODE_STRING: {
//nothing in particular
if (select_mode == SELECT_MULTI && (get_tree()->get_last_event_id() == focus_in_id || !already_cursor)) {
if (select_mode == SELECT_MULTI && (get_tree()->get_event_count() == focus_in_id || !already_cursor)) {
bring_up_editor = false;
}
@ -1863,7 +1863,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
} else {
editor_text = String::num(p_item->cells[col].val, Math::step_decimals(p_item->cells[col].step));
if (select_mode == SELECT_MULTI && get_tree()->get_last_event_id() == focus_in_id)
if (select_mode == SELECT_MULTI && get_tree()->get_event_count() == focus_in_id)
bring_up_editor = false;
}
}
@ -2786,7 +2786,7 @@ void Tree::_notification(int p_what) {
if (p_what == NOTIFICATION_FOCUS_ENTER) {
focus_in_id = get_tree()->get_last_event_id();
focus_in_id = get_tree()->get_event_count();
}
if (p_what == NOTIFICATION_MOUSE_EXIT) {

View file

@ -359,7 +359,7 @@ private:
LineEdit *text_editor;
HSlider *value_editor;
bool updating_value_editor;
uint32_t focus_in_id;
int64_t focus_in_id;
PopupMenu *popup_menu;
Vector<ColumnInfo> columns;

View file

@ -391,13 +391,12 @@ void SceneTree::input_event(const Ref<InputEvent> &p_event) {
if (Engine::get_singleton()->is_editor_hint() && (Object::cast_to<InputEventJoypadButton>(p_event.ptr()) || Object::cast_to<InputEventJoypadMotion>(*p_event)))
return; //avoid joy input on editor
current_event++;
root_lock++;
//last_id=p_event.ID;
input_handled = false;
Ref<InputEvent> ev = p_event;
ev->set_id(++last_id); //this should work better
MainLoop::input_event(ev);
@ -941,11 +940,6 @@ void SceneMainLoop::_update_listener_2d() {
}
*/
uint32_t SceneTree::get_last_event_id() const {
return last_id;
}
Variant SceneTree::_call_group_flags(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
r_error.error = Variant::CallError::CALL_OK;
@ -994,6 +988,10 @@ int64_t SceneTree::get_frame() const {
return current_frame;
}
int64_t SceneTree::get_event_count() const {
return current_event;
}
Array SceneTree::_get_nodes_in_group(const StringName &p_group) {
@ -2287,9 +2285,10 @@ SceneTree::SceneTree() {
tree_version = 1;
physics_process_time = 1;
idle_process_time = 1;
last_id = 1;
root = NULL;
current_frame = 0;
current_event = 0;
tree_changed_name = "tree_changed";
node_added_name = "node_added";
node_removed_name = "node_removed";

View file

@ -109,7 +109,6 @@ private:
float idle_process_time;
bool accept_quit;
bool quit_on_go_back;
uint32_t last_id;
#ifdef DEBUG_ENABLED
bool debug_collisions_hint;
@ -130,6 +129,7 @@ private:
bool use_font_oversampling;
int64_t current_frame;
int64_t current_event;
int node_count;
#ifdef TOOLS_ENABLED
@ -335,8 +335,6 @@ public:
_FORCE_INLINE_ Viewport *get_root() const { return root; }
uint32_t get_last_event_id() const;
void call_group_flags(uint32_t p_call_flags, const StringName &p_group, const StringName &p_function, VARIANT_ARG_LIST);
void notify_group_flags(uint32_t p_call_flags, const StringName &p_group, int p_notification);
void set_group_flags(uint32_t p_call_flags, const StringName &p_group, const String &p_name, const Variant &p_value);
@ -412,6 +410,7 @@ public:
int get_collision_debug_contact_count() { return collision_debug_contacts; }
int64_t get_frame() const;
int64_t get_event_count() const;
int get_node_count() const;

View file

@ -184,7 +184,6 @@ Viewport::GUI::GUI() {
key_focus = NULL;
mouse_over = NULL;
cancelled_input_ID = 0;
tooltip = NULL;
tooltip_popup = NULL;
tooltip_label = NULL;
@ -1620,9 +1619,6 @@ bool Viewport::_gui_drop(Control *p_at_control, Point2 p_at_pos, bool p_just_che
void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
if (p_event->get_id() == gui.cancelled_input_ID) {
return;
}
//?
/*
if (!is_visible()) {
@ -1752,7 +1748,6 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
_gui_call_input(gui.mouse_focus, mb);
}
get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, "windows", "_cancel_input_ID", mb->get_id());
get_tree()->set_input_as_handled();
if (gui.drag_data.get_type() != Variant::NIL && mb->get_button_index() == BUTTON_LEFT) {
@ -1825,7 +1820,6 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
gui.drag_data=Variant(); //always clear
}*/
get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, "windows", "_cancel_input_ID", mb->get_id());
get_tree()->set_input_as_handled();
}
}

View file

@ -269,7 +269,6 @@ private:
float tooltip_timer;
float tooltip_delay;
List<Control *> modal_stack;
unsigned int cancelled_input_ID;
Transform2D focus_inv_xform;
bool subwindow_order_dirty;
List<Control *> subwindows;