diff options
author | Morten Sørvig <[email protected]> | 2023-02-03 14:24:01 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <[email protected]> | 2023-02-03 18:49:04 +0000 |
commit | 577364b0e8933da081a3cfb3828adb03cf050266 (patch) | |
tree | bdb0107d4db1fc8e88804f156ef019358be1addf /src/plugins/platforms/wasm/qwasmaccessibility.cpp | |
parent | 79ffb2eb33f3e1d02c47a9b492c2c0d0545b9876 (diff) |
wasm: fix accessibility crash on null parent
The code was a assuming that an a11y interface always
has a parent, which is not the case for the root interface.
Also factor out to a getWindow() function, to prepare
for re-use later on.
Change-Id: I52a841bf94c712deb9603e8b9c2c878820c5f117
Reviewed-by: Mikołaj Boc <[email protected]>
(cherry picked from commit 34c36821578f39e9c7f99e1dd0e7887a52418b9d)
Reviewed-by: Qt Cherry-pick Bot <[email protected]>
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmaccessibility.cpp')
-rw-r--r-- | src/plugins/platforms/wasm/qwasmaccessibility.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/plugins/platforms/wasm/qwasmaccessibility.cpp b/src/plugins/platforms/wasm/qwasmaccessibility.cpp index e9217cbefc9..bea7380bfc1 100644 --- a/src/plugins/platforms/wasm/qwasmaccessibility.cpp +++ b/src/plugins/platforms/wasm/qwasmaccessibility.cpp @@ -113,17 +113,18 @@ emscripten::val QWasmAccessibility::getContainer(QWindow *window) emscripten::val QWasmAccessibility::getContainer(QAccessibleInterface *iface) { - QWindow *window = iface->window(); - if (!window) { - //this is needed to add tabs as the window is not available - if (iface->parent()->window()) { - window = iface->parent()->window(); - } else { - return emscripten::val::undefined(); - } - } + if (!iface) + return emscripten::val::undefined(); + return getContainer(getWindow(iface)); +} - return getContainer(window); +QWindow *QWasmAccessibility::getWindow(QAccessibleInterface *iface) +{ + QWindow *window = iface->window(); + // this is needed to add tabs as the window is not available + if (!window && iface->parent()) + window = iface->parent()->window(); + return window; } emscripten::val QWasmAccessibility::getDocument(const emscripten::val &container) |