From 77f676d69d9fee6f58787db7173f9eb580a209a2 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Tue, 25 Feb 2025 23:00:06 +0100 Subject: [PATCH] live-preview: Update the live-preview data model (#7741) ... on reloads. That is needed to make the UI aware of the new data. I tried to be clever and not update widgets on model changes, but that is not a problem anymore as all the property values are no longer passed through the model. So the only reason to update the model now is because the code was loaded fresh and we *need* to refresh the entire UI in that case. --- tools/lsp/preview/ui.rs | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/tools/lsp/preview/ui.rs b/tools/lsp/preview/ui.rs index 223e86cc9..5a4712645 100644 --- a/tools/lsp/preview/ui.rs +++ b/tools/lsp/preview/ui.rs @@ -1142,32 +1142,7 @@ pub fn ui_set_preview_data( let api = ui.global::(); - let old_model = api.get_preview_data(); - - fn update_model( - old_model: &slint::ModelRc, - new_model: &[PropertyContainer], - ) -> bool { - if old_model.row_count() != new_model.len() { - return true; - } - - for (oc, nc) in old_model.iter().zip(new_model.iter()) { - if oc.container_name != nc.container_name - || oc.container_id != nc.container_id - || oc.properties.row_count() != nc.properties.row_count() - || oc.properties.iter().zip(nc.properties.iter()).any(|(o, n)| o != n) - { - return true; - } - } - - false - } - - if update_model(&old_model, &result) { - api.set_preview_data(Rc::new(VecModel::from(result)).into()); - } + api.set_preview_data(Rc::new(VecModel::from(result)).into()); } fn to_property_container(container: slint::SharedString) -> preview_data::PropertyContainer {