Android: Fix crash when parent window is detached but view reference remains

This commit addresses a crash that occurs when the parent window is
destroyed while the view reference is still held. The crash happens when
the callback onAttachedToWindow is triggered and the
QuickView.createQuickView() function is called in native code. In this
scenario, the view reference is still pointing to the previous QuickView
whose parent has already been cleared, causing the crash.

To fix this, we reset the reference to 0 when the parent is deleted or
destroyed. This ensures that when onAttachedToWindow is called again,
the view is properly recreated after its underlying window has been
destroyed.

Fixes: QTBUG-138922
Change-Id: Ia39eb83b58af19cd9b881915215b2be2adcfee49
(cherry picked from commit 8194e979fc58f71244f625f320a797d4550524c9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit e205d6b2ac)
(cherry picked from commit e893262b06)
This commit is contained in:
Ahmed El Khazari 2025-08-11 07:54:51 +03:00 committed by Qt Cherry-pick Bot
parent 4bf60d0a64
commit 6f0d27d2e4
1 changed files with 1 additions and 0 deletions

View File

@ -200,6 +200,7 @@ abstract class QtView extends ViewGroup implements QtNative.AppStateDetailsListe
if (m_parentWindowReference != 0L)
deleteWindow(m_parentWindowReference);
m_parentWindowReference = 0L;
setWindowReference(0L);
}
QtWindow getQtWindow() {