Skip to content

Fix crash when selecting City with no offline city list - #4

Merged
pQu4k3r merged 1 commit into
mainfrom
develop
Sep 9, 2026
Merged

Fix crash when selecting City with no offline city list#4
pQu4k3r merged 1 commit into
mainfrom
develop

Conversation

@pQu4k3r

@pQu4k3r pQu4k3r commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a real crash reported after a fresh install, from the Enigma2 crash log:

FileNotFoundError: [Errno 2] No such file or directory: '/etc/enigma2/foreca/new_city.cfg'
...
TypeError: Foreca_Preview.city_selected() missing 1 required positional argument: 'result'
  • city_panel.py: prepare_city_list() correctly detected a missing new_city.cfg and opened a "file not found" warning, but then fell through into the open() call unconditionally anyway, raising FileNotFoundError (caught internally by the surrounding try/except, so not fatal on its own, but pointless). Missing return after showing the warning — added it, and also made the warning message point the user at the search feature instead.
  • plugin.py: the actual crash. The warning MessageBox's callback (_close_panel) called self.close() with no arguments. Foreca_Preview.city_selected requires a positional result argument with no default, so the callback dispatch itself raised TypeError, which is what produced the blue-screen error (not the FileNotFoundError, which was already handled). Fixed both ends: _close_panel now closes with an explicit None (matching city_selected's existing if result is None: return handling), and city_selected got a result=None default so any other callback-with-no-args path can't hit the same crash.

Note (not fixed here)

new_city.cfg is only ever read in the codebase, never written. README claims "the plugin create[s] it automatically during a search," but that mechanism doesn't actually exist — this is a documentation/feature gap, separate from the crash fixed in this PR.

Reported crash log:
- city_panel.py: prepare_city_list() detected a missing
  new_city.cfg and opened a warning MessageBox, but then fell
  through into the open() call unconditionally anyway, raising
  FileNotFoundError (caught internally, but pointless). Missing
  `return` after showing the warning.
- plugin.py: the MessageBox's callback (_close_panel) called
  self.close() with no arguments, and Foreca_Preview.city_selected
  required a positional `result` argument with no default, so the
  callback dispatch crashed with TypeError, producing the blue-screen
  error. Fixed both: _close_panel now closes with an explicit None
  (matching city_selected's existing `if result is None: return`
  handling), and city_selected got a `result=None` default so any
  other callback-with-no-args path can't hit the same crash.

Note: new_city.cfg is only ever read, never written anywhere in the
codebase - README's claim that the plugin creates it automatically
during a search isn't actually implemented. Flagging this separately
as a documentation/feature gap, not fixed here.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UPpumFb2PP21ATpDwJBYBB
@pQu4k3r
pQu4k3r merged commit 6897c22 into main Sep 9, 2026
6 checks passed
pQu4k3r added a commit that referenced this pull request Sep 9, 2026
…ning

Reported: opening Select City with no offline new_city.cfg showed
"City list file not found" twice, then dropped back to the main
plugin screen instead of staying on a usable search panel.

Root causes:
- onShown fires more than once per screen open in Enigma2, and
  prepare_city_list() was bound directly to onShown with no guard,
  so the warning popped up on every firing.
- The warning's callback closed the entire CityPanel4 screen
  (self.close(None)), not just the popup, contradicting its own
  "use the search" message since the search screen no longer
  existed by the time the user could act on it.

Fixed by guarding the warning to show once per screen instance, and
leaving CityPanel4 open afterward (with an empty list) so the user
can press RED to search online, per PR #4's Test plan note that this
mechanism needed follow-up.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UPpumFb2PP21ATpDwJBYBB
pQu4k3r added a commit that referenced this pull request Sep 10, 2026
README documents that the offline city list "is created automatically
during a search" if it doesn't exist, but that mechanism was never
actually implemented anywhere in the codebase - new_city.cfg was only
ever read, never written.

Implemented it: after a successful online search (search_online),
append any newly found cities to new_city.cfg, deduped by city id
against what's already in the file, in the same "ID/City_Name" format
the reader already expects (verified with a write/read round-trip,
including a non-ASCII city name). Creates SYSTEM_DIR if needed,
mirroring the pattern already used elsewhere (e.g. ForecaSetup.save
in plugin.py). The offline list now builds up over time as users
search, so City Selection's offline browsing (and search_offline's
fallback) actually has something to work with after the fix in #4/#5.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UPpumFb2PP21ATpDwJBYBB
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