Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent double loading by having the tree model be a single source of truth #75

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

psobolewskiPhD
Copy link
Collaborator

@psobolewskiPhD psobolewskiPhD commented Jan 9, 2025

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.

@psobolewskiPhD psobolewskiPhD marked this pull request as ready for review January 9, 2025 17:57
@psobolewskiPhD psobolewskiPhD added the bug Something isn't working label Jan 9, 2025
Copy link

codecov bot commented Jan 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 33.25%. Comparing base (1d53966) to head (141c8bf).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #75      +/-   ##
==========================================
+ Coverage   33.13%   33.25%   +0.11%     
==========================================
  Files          13       13              
  Lines         845      842       -3     
==========================================
  Hits          280      280              
+ Misses        565      562       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[0.3.0] Selecting image in the list still causes double loading, sometimes seg fault
1 participant