Ignore deleted windows when saving session.

This hopefully helps with a crash on Windows which happens from time to time
during some multi-window tabs.feature tests:

Traceback (most recent call last):
  File "...\mainwindow\mainwindow.py", line 446, in closeEvent
    self._do_close()
  File "...\mainwindow\mainwindow.py", line 405, in _do_close
    objreg.get('session-manager').save_last_window_session()
  File "...\misc\sessions.py", line 247, in save_last_window_session
    self._last_window_session = self._save_all()
  File "...\misc\sessions.py", line 183, in _save_all
    win_data['geometry'] = bytes(main_window.saveGeometry())
RuntimeError: wrapped C/C++ object of type MainWindow has been deleted
This commit is contained in:
Florian Bruhin 2015-11-28 20:30:41 +01:00
parent f847ddf3cb
commit 8cf6ace0e7

View File

@ -20,6 +20,7 @@
"""Management of sessions - saved tabs/windows."""
import os
import sip
import os.path
from PyQt5.QtCore import pyqtSignal, QUrl, QObject, QPoint, QTimer
@ -176,6 +177,11 @@ class SessionManager(QObject):
window=win_id)
main_window = objreg.get('main-window', scope='window',
window=win_id)
# We could be in the middle of destroying a window here
if sip.isdeleted(main_window):
continue
win_data = {}
active_window = QApplication.instance().activeWindow()
if getattr(active_window, 'win_id', None) == win_id: