From 7a85ae03b6d2d0ea7dae21c0f340615c8e90ffff Mon Sep 17 00:00:00 2001 From: Adam Wierzchowski Date: Fri, 21 Aug 2015 10:57:14 -0400 Subject: [PATCH] python/tk_multi_loader: add comments in reselecting --- python/tk_multi_loader/dialog.py | 3 +++ python/tk_multi_loader/model_entity.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/python/tk_multi_loader/dialog.py b/python/tk_multi_loader/dialog.py index c43de380..84291c88 100644 --- a/python/tk_multi_loader/dialog.py +++ b/python/tk_multi_loader/dialog.py @@ -779,6 +779,9 @@ def _on_home_clicked(self): found_preset = self.ui.entity_preset_tabs.tabText(0) if found_model and found_item: + # store current selection data in case model is refreshed. If this happens selection will be lost + # and user will have to press home again. This data will be used in SgEntityModel to restore + # selection after new data is fed into model. found_model.reSelector['entity'] = found_item.get_sg_data() found_model.reSelector['found_preset'] = found_preset found_model.reSelector['sel_func'] = self._select_item_in_entity_tree diff --git a/python/tk_multi_loader/model_entity.py b/python/tk_multi_loader/model_entity.py index 4360279b..1d61dfb4 100644 --- a/python/tk_multi_loader/model_entity.py +++ b/python/tk_multi_loader/model_entity.py @@ -54,6 +54,12 @@ def __init__(self, parent, entity_type, filters, hierarchy, bg_task_manager): fields=["image", "sg_status_list", "description"] self._load_data(entity_type, filters, hierarchy, fields) + # this dict holds entity which was selected in dialog after model was filled. This selection + # is result of self._on_home_clicked() executed at last line of _load_entity_presets() + # reSelector will be used only once in data_refreshed_cb to restore selection if items in model + # were destroyed and created again as result of differences between local shotgun disc cache + # and actual shotgun data + # see __on_sg_data_arrived(...) in class ShotgunModel self.reSelector = {'entity': None, 'found_preset': None, 'dialog': parent,