popout: guard against None centralWidget and QApplication during teardown
resizeEvent, installEventFilter, and removeEventFilter all dereference return values that can be None during init/shutdown, causing AttributeError crashes on edge-case lifecycle timing.
This commit is contained in:
parent
2cdab574ca
commit
3d26e40e0f
@ -287,7 +287,9 @@ class FullscreenPreview(QMainWindow):
|
|||||||
self._stack.setMouseTracking(True)
|
self._stack.setMouseTracking(True)
|
||||||
|
|
||||||
from PySide6.QtWidgets import QApplication
|
from PySide6.QtWidgets import QApplication
|
||||||
QApplication.instance().installEventFilter(self)
|
app = QApplication.instance()
|
||||||
|
if app is not None:
|
||||||
|
app.installEventFilter(self)
|
||||||
# Pick target monitor
|
# Pick target monitor
|
||||||
target_screen = None
|
target_screen = None
|
||||||
if monitor and monitor != "Same as app":
|
if monitor and monitor != "Same as app":
|
||||||
@ -1631,8 +1633,11 @@ class FullscreenPreview(QMainWindow):
|
|||||||
def resizeEvent(self, event) -> None:
|
def resizeEvent(self, event) -> None:
|
||||||
super().resizeEvent(event)
|
super().resizeEvent(event)
|
||||||
# Position floating overlays
|
# Position floating overlays
|
||||||
w = self.centralWidget().width()
|
central = self.centralWidget()
|
||||||
h = self.centralWidget().height()
|
if central is None:
|
||||||
|
return
|
||||||
|
w = central.width()
|
||||||
|
h = central.height()
|
||||||
tb_h = self._toolbar.sizeHint().height()
|
tb_h = self._toolbar.sizeHint().height()
|
||||||
self._toolbar.setGeometry(0, 0, w, tb_h)
|
self._toolbar.setGeometry(0, 0, w, tb_h)
|
||||||
ctrl_h = self._video._controls_bar.sizeHint().height()
|
ctrl_h = self._video._controls_bar.sizeHint().height()
|
||||||
@ -1756,7 +1761,9 @@ class FullscreenPreview(QMainWindow):
|
|||||||
FullscreenPreview._saved_geometry = QRect(x, y, w, h)
|
FullscreenPreview._saved_geometry = QRect(x, y, w, h)
|
||||||
else:
|
else:
|
||||||
FullscreenPreview._saved_geometry = self.frameGeometry()
|
FullscreenPreview._saved_geometry = self.frameGeometry()
|
||||||
QApplication.instance().removeEventFilter(self)
|
app = QApplication.instance()
|
||||||
|
if app is not None:
|
||||||
|
app.removeEventFilter(self)
|
||||||
# Snapshot video position BEFORE StopMedia destroys it.
|
# Snapshot video position BEFORE StopMedia destroys it.
|
||||||
# _on_fullscreen_closed reads this via get_video_state() to
|
# _on_fullscreen_closed reads this via get_video_state() to
|
||||||
# seek the embedded preview to the same position.
|
# seek the embedded preview to the same position.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user