openmc-dev / plotter

Native plotting GUI for model design and verification
MIT License
48 stars 18 forks source link

Prevent potential issue with shortcutOverlay not being recognized #151

Closed paulromano closed 5 months ago

paulromano commented 5 months ago

When the plotter is loading up, some previous settings are loaded via the QSettings class: https://github.com/openmc-dev/plotter/blob/d7ac96ac127f755f87b40b1fa96f008ff3818192/openmc_plotter/main_window.py#L1079-L1083

We've gotten reports from users recently that the call to restoreState results in an exception as follows:

File “.../lib/python3.11/site-packages/openmc_plotter/main_window.py”, line 1158, in resizeEvent
if self.shortcutOverlay.isVisible():
^^^^^^^^^^^^^^^^^^^^
AttributeError: ‘MainWindow’ object has no attribute ‘shortcutOverlay’

I suspect this might actually be a bug in PySide6, but nevertheless the changes in this PR should hopefully prevent problems by moving the creation of the shortcutOverlay attribute to before we call restoreState.