diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-09-01 19:49:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-01 19:49:29 +0200 |
commit | 9be18addb1c63189b3b5a88e4ff013079f69f420 (patch) | |
tree | ecd4d7f3b51c7484b93d73fd89d6c66242dad801 /editor/editor_data.cpp | |
parent | 52013cdee382aa99c97d68ca95dad3f3a645bdf0 (diff) | |
parent | 2b44b0cc43fa61253f54654617252bafbdba4714 (diff) |
Merge pull request #37022 from aaronfranke/editor-plugin-iter-back
Iterate backwards over EditorPlugin's list of plugins in get_editor etc
Diffstat (limited to 'editor/editor_data.cpp')
-rw-r--r-- | editor/editor_data.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 130c330f5a..5118ccacad 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -262,7 +262,9 @@ EditorHistory::EditorHistory() { } EditorPlugin *EditorData::get_editor(Object *p_object) { - for (int i = 0; i < editor_plugins.size(); i++) { + // We need to iterate backwards so that we can check user-created plugins first. + // Otherwise, it would not be possible for plugins to handle CanvasItem and Spatial nodes. + for (int i = editor_plugins.size() - 1; i > -1; i--) { if (editor_plugins[i]->has_main_screen() && editor_plugins[i]->handles(p_object)) { return editor_plugins[i]; } @@ -272,7 +274,7 @@ EditorPlugin *EditorData::get_editor(Object *p_object) { } EditorPlugin *EditorData::get_subeditor(Object *p_object) { - for (int i = 0; i < editor_plugins.size(); i++) { + for (int i = editor_plugins.size() - 1; i > -1; i--) { if (!editor_plugins[i]->has_main_screen() && editor_plugins[i]->handles(p_object)) { return editor_plugins[i]; } @@ -283,7 +285,7 @@ EditorPlugin *EditorData::get_subeditor(Object *p_object) { Vector<EditorPlugin *> EditorData::get_subeditors(Object *p_object) { Vector<EditorPlugin *> sub_plugins; - for (int i = 0; i < editor_plugins.size(); i++) { + for (int i = editor_plugins.size() - 1; i > -1; i--) { if (!editor_plugins[i]->has_main_screen() && editor_plugins[i]->handles(p_object)) { sub_plugins.push_back(editor_plugins[i]); } @@ -292,7 +294,7 @@ Vector<EditorPlugin *> EditorData::get_subeditors(Object *p_object) { } EditorPlugin *EditorData::get_editor(String p_name) { - for (int i = 0; i < editor_plugins.size(); i++) { + for (int i = editor_plugins.size() - 1; i > -1; i--) { if (editor_plugins[i]->get_name() == p_name) { return editor_plugins[i]; } |