Skip to content

Fails on OSX due to Qsettings.allKeys() behavior #3

@KM4YRI

Description

@KM4YRI

Gives the following error on a clean install, in OSX:

Traceback (most recent call last):
  File "/usr/local/bin/pymorsetrainer", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/site-packages/pymorsetrainer/__main__.py", line 28, in main
    mw = MainWindow()
  File "/usr/local/lib/python3.8/site-packages/pymorsetrainer/pymorsetrainer.py", line 53, in __init__
    self.initUI()
  File "/usr/local/lib/python3.8/site-packages/pymorsetrainer/pymorsetrainer.py", line 98, in initUI
    lessonCombo.setCurrentIndex(int(self.settings.value("currentLesson"))-1)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

This is an OSX quirk. self.settings.allKeys() will always return truthy on OSX, even on the first startup. OSX shoves in all sorts of parameters like com/apple/trackpad/twoFingerDoubleTapGesture and com/apple/TimeZonePref/Last_Selected_City. And in your case, the settings.setValue() calls never get called. A proposed fix would be to test if any of those five values return None, and if so, write them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions