Merge pull request #14802 from volzhs/selection-changed
Fix "selection_changed" called twice
This commit is contained in:
commit
99eb394a5f
2 changed files with 13 additions and 1 deletions
|
@ -880,6 +880,7 @@ void EditorSelection::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("remove_node", "node"), &EditorSelection::remove_node);
|
ClassDB::bind_method(D_METHOD("remove_node", "node"), &EditorSelection::remove_node);
|
||||||
ClassDB::bind_method(D_METHOD("get_selected_nodes"), &EditorSelection::_get_selected_nodes);
|
ClassDB::bind_method(D_METHOD("get_selected_nodes"), &EditorSelection::_get_selected_nodes);
|
||||||
ClassDB::bind_method(D_METHOD("get_transformable_selected_nodes"), &EditorSelection::_get_transformable_selected_nodes);
|
ClassDB::bind_method(D_METHOD("get_transformable_selected_nodes"), &EditorSelection::_get_transformable_selected_nodes);
|
||||||
|
ClassDB::bind_method(D_METHOD("_emit_change"), &EditorSelection::_emit_change);
|
||||||
ADD_SIGNAL(MethodInfo("selection_changed"));
|
ADD_SIGNAL(MethodInfo("selection_changed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -923,7 +924,15 @@ void EditorSelection::update() {
|
||||||
if (!changed)
|
if (!changed)
|
||||||
return;
|
return;
|
||||||
changed = false;
|
changed = false;
|
||||||
|
if (!emitted) {
|
||||||
|
emitted = true;
|
||||||
|
call_deferred("_emit_change");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorSelection::_emit_change() {
|
||||||
emit_signal("selection_changed");
|
emit_signal("selection_changed");
|
||||||
|
emitted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Node *> &EditorSelection::get_selected_node_list() {
|
List<Node *> &EditorSelection::get_selected_node_list() {
|
||||||
|
@ -947,6 +956,7 @@ void EditorSelection::clear() {
|
||||||
}
|
}
|
||||||
EditorSelection::EditorSelection() {
|
EditorSelection::EditorSelection() {
|
||||||
|
|
||||||
|
emitted = false;
|
||||||
changed = false;
|
changed = false;
|
||||||
nl_changed = false;
|
nl_changed = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,9 +210,10 @@ class EditorSelection : public Object {
|
||||||
|
|
||||||
GDCLASS(EditorSelection, Object);
|
GDCLASS(EditorSelection, Object);
|
||||||
|
|
||||||
public:
|
private:
|
||||||
Map<Node *, Object *> selection;
|
Map<Node *, Object *> selection;
|
||||||
|
|
||||||
|
bool emitted;
|
||||||
bool changed;
|
bool changed;
|
||||||
bool nl_changed;
|
bool nl_changed;
|
||||||
|
|
||||||
|
@ -224,6 +225,7 @@ public:
|
||||||
void _update_nl();
|
void _update_nl();
|
||||||
Array _get_selected_nodes();
|
Array _get_selected_nodes();
|
||||||
Array _get_transformable_selected_nodes();
|
Array _get_transformable_selected_nodes();
|
||||||
|
void _emit_change();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
Loading…
Reference in a new issue