himselfv / wakan

Japanese and Chinese learning tool with dictionary
36 stars 7 forks source link

Editor: AV when auto-loading file on start #290

Closed himselfv closed 6 years ago

himselfv commented 6 years ago

Original report by me.

Reported in Issue 286. When auto-loading last used file is enabled in settings, and last used file was .txt (.wtt works fine), the app crashes on start.

Confirmed, fixed.

Was a conjunction of several deficiencies:

  1. The app shouldn't crash when it cannot load the last used file. Most of the time it's a minor problem (e.g. file was moved), even when it's a problem in code, the initialization is already over so the app can handle it like a normal exception (notify but continue).

Fixed by moving this initialization code block into its separate try/except which allows for continuation.

  1. The stored file encoding information was being read from the wrong registry field. Fixed.

  2. I thought about auto-detecting encoding when the stored encoding cannot be re-instantiated anyway, but decided against it. Encodings don't just drop out of Wakan daily; any stored encodings should remain. If for any reason we can't find them, that's a problem and should be treated as such, not band-aided.