Prevent double loading by having the tree model be a single source of truth #75
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes: #73
My understanding is that expanding items was triggering the
fetch
methods from the model, adding items to the tree. But it doesn't involve selection. And without selection, the thumbnails are not updated and become out of sync with the tree model.Then, when you click on an item in the tree it sets the item in the model and the thumbnail grid. Both involve interactions with the Blitz gateway and I think this was creating some sort of race condition leading to the seg faults I observe.
Additionally, setting the thumbnail selection triggered
load_image
, as did selecting the item in the list.I think the solution from #61 doesn't work anymore because the image loading from the thumbnail happens second, after the tree item selection -- because when expanding there is no thumbnail (see #74).
So in this PR, I remove the
load_image
from the thumbnail selection callback, so only tree view item selection loads images. This makes the tree model the source of truth, regardless of the thumbnail state.Then we can remove the code from #64 because there is only one way to actually load images -- via the tree model selection. The thumbnail selection is just a proxy for setting the selected tree item.
Note: this does not address the fact that as of #46 images are not removed when new images are loaded.
I will make a separate PR for that.
Likewise, having expanding trigger selection (#74) has value, because it triggers loading of thumbnails when the user expands the tree. I think this is a worthwhile enhancement of it's own.