1
0

qt: main_window: fix init_geometry

probably regression from qt6 migration

Don't use broad generic "except Exception" without at least logging the exception, please...
That's why this was not noticed before, the exception was being swallowed.

Nevertheless, on Linux with wayland, this still does not work (the geometry API is getting dumb values).
On x11 it now works again, as well as on Windows. (haven't tested macos)

```
  7.78 | I | gui.qt.main_window.[9dk] | using default geometry
Traceback (most recent call last):
  File "...\electrum\electrum\gui\qt\main_window.py", line 538, in init_geometry
    screen = self.app.desktop().screenGeometry()
AttributeError: 'QElectrumApplication' object has no attribute 'desktop'
```
This commit is contained in:
SomberNight
2025-03-20 19:10:28 +00:00
parent e9335f5cc7
commit 937b157d29

View File

@@ -533,12 +533,16 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
send_exception_to_crash_reporter(e)
def init_geometry(self):
# note: does not support multiple monitors well
winpos = self.wallet.db.get("winpos-qt")
try:
screen = self.app.desktop().screenGeometry()
assert screen.contains(QRect(*winpos))
self.setGeometry(*winpos)
except Exception:
winrect = QRect(*winpos)
except TypeError:
winrect = None
screen = self.app.primaryScreen().geometry()
if winrect and screen.contains(winrect):
self.setGeometry(winrect)
else:
self.logger.info("using default geometry")
self.setGeometry(100, 100, 840, 400)