From 23f48a597738f17852048771fe4c75098a45e1bb Mon Sep 17 00:00:00 2001 From: Tristan Simas Date: Tue, 17 Nov 2026 02:40:29 -0500 Subject: [PATCH] Qt sidebar widgets: force Qt.Widget flag at construction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Passing parent= alone wasn't enough on Qt-for-Android: src/toad/qt/window.py's _layout_panes calls bar.setParent(None) during rearrangement, and in the window between that call and the next setParent(dock) Qt treats the widget as a top-level QWindow and gives it its own EGL surface — same crash as a true orphan. Second SidebarToggleClassWindow still races QtAndroidAccessibility::runInObjectContext() one second after ApplicationActive. setWindowFlags(Qt.WindowType.Widget) tells Qt explicitly: this is a child widget, never a window, even when parent is None. Qt then refuses to allocate a top-level window for the transient parent-less state. Co-Authored-By: Claude Opus 4.7 Claude-Session: https://claude.ai/code/session_016gZLdupVQyBzHTmHBC9Cyn --- src/formbridge/widgets/sidebar.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/formbridge/widgets/sidebar.py b/src/formbridge/widgets/sidebar.py index 6aee930..a5e7b0e 100644 --- a/src/formbridge/widgets/sidebar.py +++ b/src/formbridge/widgets/sidebar.py @@ -84,6 +84,12 @@ def __init__(self, action: PlacementAction, layout: PlacementLayout, identity: object, applied: Callable[[], None], parent: QWidget | None = None) -> None: super().__init__(parent) + # Keep this a child widget even when transiently reparented to None during + # layout rearrangement. Without Qt.Widget, Qt-for-Android gives any parent-less + # QWidget its own top-level QWindow + EGL surface; the second surface races + # QtAndroidAccessibility::runInObjectContext() for the eglSurface() mutex and + # trips the deadlock protector (SIGABRT a second after ApplicationActive). + self.setWindowFlags(Qt.WindowType.Widget) self.action = action self._layout = layout self._identity = identity @@ -126,6 +132,7 @@ def __init__(self, layout: PlacementLayout, identity: object, applied: Callable[[], None], parent: QWidget | None = None) -> None: super().__init__(parent) + self.setWindowFlags(Qt.WindowType.Widget) self._layout = layout self._identity = identity self._owner = owner @@ -205,6 +212,7 @@ def __init__(self, layout: PlacementLayout, identity: object, *, toggled: Callable[[], None], parent: QWidget | None = None) -> None: super().__init__(parent) + self.setWindowFlags(Qt.WindowType.Widget) self._layout = layout self._identity = identity self._heading = heading