Android: Check input delegate for null when QtView attached to window

If the Qt libs have not been loaded before the QtView is attached to
the window, it leads to accessing the input delegate, which only gets
initialized after the creation of the libs, so we get a null pointer
expection. Add a null check, and a boolean to make sure we update
the input delegate with the view once the libraries are loaded
and the input delegate has been created.

Task-number: QTBUG-126177
Change-Id: I7372596884c7d0ed6c9cca812b46399ecfb74367
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit dc62ddd1521a5754aec0031ade17743da3ed0585)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tinja Paavoseppä 2024-06-13 12:35:53 +03:00 committed by Qt Cherry-pick Bot
parent 5922437534
commit 4d6fd8302e

View File

@ -105,6 +105,7 @@ class QtEmbeddedDelegate extends QtActivityDelegateBase
BackendRegister.unregisterBackend(QtMenuInterface.class);
BackendRegister.unregisterBackend(QtLayoutInterface.class);
}
updateInputDelegate();
}
}
@ -168,11 +169,14 @@ class QtEmbeddedDelegate extends QtActivityDelegateBase
// QtEmbeddedViewInterface implementation end
private void updateInputDelegate() {
if (m_view == null) {
m_inputDelegate.setEditPopupMenu(null);
// If the QtView has attached to the window before Qt libs have been loaded,
// the input delegate will be null
if (m_inputDelegate == null)
return;
}
m_inputDelegate.setEditPopupMenu(new EditPopupMenu(m_activity, m_view));
if (m_view == null)
m_inputDelegate.setEditPopupMenu(null);
else
m_inputDelegate.setEditPopupMenu(new EditPopupMenu(m_activity, m_view));
}
private void createRootWindow() {