Android: fix crash when subclassing the QtActivity
m_context.getClass() returns the top class and this way QtApplication can't find the proper class Name (QtActivity and QtService). This patch passes the right class names to QtLoader/QtApplication. Task-number: QTBUG-52373 Change-Id: Ib69446cdaa38ac8b489872c4850210e5d503492e Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>bb10
parent
40ece5edcf
commit
ba30566b25
|
|
@ -55,7 +55,7 @@ public class QtActivityLoader extends QtLoader {
|
|||
|
||||
QtActivityLoader(QtActivity activity)
|
||||
{
|
||||
super(activity);
|
||||
super(activity, QtActivity.class);
|
||||
m_activity = activity;
|
||||
}
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -133,8 +133,11 @@ public class QtApplication extends Application
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (-1 == stackDeep)
|
||||
return result;
|
||||
|
||||
final String methodName=elements[stackDeep].getMethodName();
|
||||
if (-1 == stackDeep || !m_delegateMethods.containsKey(methodName))
|
||||
if (!m_delegateMethods.containsKey(methodName))
|
||||
return result;
|
||||
|
||||
for (Method m : m_delegateMethods.get(methodName)) {
|
||||
|
|
|
|||
|
|
@ -152,9 +152,11 @@ public abstract class QtLoader {
|
|||
public int m_displayDensity = -1;
|
||||
private ContextWrapper m_context;
|
||||
protected ComponentInfo m_contextInfo;
|
||||
private Class<?> m_delegateClass;
|
||||
|
||||
QtLoader(ContextWrapper context) {
|
||||
QtLoader(ContextWrapper context, Class<?> clazz) {
|
||||
m_context = context;
|
||||
m_delegateClass = clazz;
|
||||
}
|
||||
|
||||
// Implement in subclass
|
||||
|
|
@ -235,7 +237,7 @@ public abstract class QtLoader {
|
|||
if (!(Boolean)prepareAppMethod.invoke(qtLoader, m_context, classLoader, loaderParams))
|
||||
throw new Exception("");
|
||||
|
||||
QtApplication.setQtContextDelegate(m_context.getClass(), qtLoader);
|
||||
QtApplication.setQtContextDelegate(m_delegateClass, qtLoader);
|
||||
|
||||
// now load the application library so it's accessible from this class loader
|
||||
if (libName != null)
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ import android.content.pm.PackageManager;
|
|||
public class QtServiceLoader extends QtLoader {
|
||||
QtService m_service;
|
||||
QtServiceLoader(QtService service) {
|
||||
super(service);
|
||||
super(service, QtService.class);
|
||||
m_service = service;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue