Skip to content

Fix UnboundLocalError in GUI on_populate_tree_lists method leading to unresponsive left panel #428

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

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

Conversation

JuanJesusAlejoSillero
Copy link

Summary

This pull request fixes a bug in the on_populate_tree_lists method where the left panel could become unresponsive when processing unexpected item types in user lists.

Details

The issue occurred when an item in the user_lists did not match the expected types (UserPlaylist, Playlist, or Mix). This left the twi_child variable uninitialized, causing the following error:

> tidal-dl-ng-gui
Login successful. Have fun!
All setup.
Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/tidal_dl_ng/gui.py", line 364, in on_populate_tree_lists
    twi_child.setText(0, name)
    ^^^^^^^^^
UnboundLocalError: cannot access local variable 'twi_child' where it is not associated with a value

While the application itself did not crash, the left panel became unresponsive.

Fix

Added an else: continue clause to ensure unsupported items are skipped, preventing the twi_child variable from being accessed without initialization.

Testing

Tested with various user list combinations, including unsupported item types, to confirm that the left panel now loads correctly without issues.


If you have additional test cases or encounter related issues, feel free to provide feedback. Thanks for reviewing this PR!

- Added a safeguard to skip items in `user_lists` that do not match expected types (`UserPlaylist`, `Playlist`, or `Mix`).
- Ensured `twi_child` is only accessed when properly initialized.
- This prevents crashes during GUI interaction when unexpected data is encountered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant