summaryrefslogtreecommitdiff
path: root/editor/plugins/theme_editor_plugin.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-06-13 15:44:32 +0200
committerGitHub <noreply@github.com>2021-06-13 15:44:32 +0200
commit12e0f10c74e9619262f1edcfdc1840432ada0565 (patch)
tree44faf2e69ad0155a0fcc2184c93a5e26d16e48d1 /editor/plugins/theme_editor_plugin.cpp
parent4ebf248e1bd12c9faf7c2d19fdef3b41b9766aee (diff)
parent9cd96ebe0e5db4cd55a4bb73ab7b4dab4d344090 (diff)
Merge pull request #49227 from pycbouh/editor-theme-freeze-changes
Prevent `Theme` resource from emitting changes during bulk operations
Diffstat (limited to 'editor/plugins/theme_editor_plugin.cpp')
-rw-r--r--editor/plugins/theme_editor_plugin.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index 7d38a8cb98..d1652d3fce 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -756,7 +756,9 @@ void ThemeItemImportTree::_import_selected() {
return;
}
- ProgressDialog::get_singleton()->add_task("import_theme_items", TTR("Importing Theme Items"), selected_items.size());
+ // Prevent changes from immediatelly being reported while the operation is still ongoing.
+ edited_theme->_freeze_change_propagation();
+ ProgressDialog::get_singleton()->add_task("import_theme_items", TTR("Importing Theme Items"), selected_items.size() + 2);
int idx = 0;
for (Map<ThemeItem, ItemCheckedState>::Element *E = selected_items.front(); E; E = E->next()) {
@@ -814,6 +816,12 @@ void ThemeItemImportTree::_import_selected() {
idx++;
}
+ // Allow changes to be reported now that the operation is finished.
+ ProgressDialog::get_singleton()->task_step("import_theme_items", TTR("Updating the editor"), idx++);
+ edited_theme->_unfreeze_and_propagate_changes();
+ // Make sure the task is not ended before the editor freezes to update the Inspector.
+ ProgressDialog::get_singleton()->task_step("import_theme_items", TTR("Finalizing"), idx++);
+
ProgressDialog::get_singleton()->end_task("import_theme_items");
emit_signal("items_imported");
}
@@ -1488,15 +1496,24 @@ void ThemeItemEditorDialog::_add_theme_item(Theme::DataType p_data_type, String
void ThemeItemEditorDialog::_remove_data_type_items(Theme::DataType p_data_type, String p_item_type) {
List<StringName> names;
+ // Prevent changes from immediatelly being reported while the operation is still ongoing.
+ edited_theme->_freeze_change_propagation();
+
edited_theme->get_theme_item_list(p_data_type, p_item_type, &names);
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
edited_theme->clear_theme_item(p_data_type, E->get(), p_item_type);
}
+
+ // Allow changes to be reported now that the operation is finished.
+ edited_theme->_unfreeze_and_propagate_changes();
}
void ThemeItemEditorDialog::_remove_class_items() {
List<StringName> names;
+ // Prevent changes from immediatelly being reported while the operation is still ongoing.
+ edited_theme->_freeze_change_propagation();
+
for (int dt = 0; dt < Theme::DATA_TYPE_MAX; dt++) {
Theme::DataType data_type = (Theme::DataType)dt;
@@ -1509,12 +1526,18 @@ void ThemeItemEditorDialog::_remove_class_items() {
}
}
+ // Allow changes to be reported now that the operation is finished.
+ edited_theme->_unfreeze_and_propagate_changes();
+
_update_edit_item_tree(edited_item_type);
}
void ThemeItemEditorDialog::_remove_custom_items() {
List<StringName> names;
+ // Prevent changes from immediatelly being reported while the operation is still ongoing.
+ edited_theme->_freeze_change_propagation();
+
for (int dt = 0; dt < Theme::DATA_TYPE_MAX; dt++) {
Theme::DataType data_type = (Theme::DataType)dt;
@@ -1527,12 +1550,18 @@ void ThemeItemEditorDialog::_remove_custom_items() {
}
}
+ // Allow changes to be reported now that the operation is finished.
+ edited_theme->_unfreeze_and_propagate_changes();
+
_update_edit_item_tree(edited_item_type);
}
void ThemeItemEditorDialog::_remove_all_items() {
List<StringName> names;
+ // Prevent changes from immediatelly being reported while the operation is still ongoing.
+ edited_theme->_freeze_change_propagation();
+
for (int dt = 0; dt < Theme::DATA_TYPE_MAX; dt++) {
Theme::DataType data_type = (Theme::DataType)dt;
@@ -1543,6 +1572,9 @@ void ThemeItemEditorDialog::_remove_all_items() {
}
}
+ // Allow changes to be reported now that the operation is finished.
+ edited_theme->_unfreeze_and_propagate_changes();
+
_update_edit_item_tree(edited_item_type);
}