Android: Fix crash at exit
We need to remove and release the surface imediately, otherwise setSurface might be called after the object is deleted. Task-number: QTBUG-59818 Change-Id: I3a09e3de1ceecc22d8d7a48e2fc1cfe40cf09f0a Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Mathias Hasselmann <mathias.hasselmann@kdab.com> Reviewed-by: Christian Stromme <christian.stromme@qt.io>
This commit is contained in:
parent
2099709a72
commit
6c4cbd4122
@ -402,11 +402,16 @@ namespace QtAndroid
|
||||
if (surfaceId == -1)
|
||||
return;
|
||||
|
||||
QJNIEnvironmentPrivate env;
|
||||
if (!env)
|
||||
return;
|
||||
{
|
||||
QMutexLocker lock(&m_surfacesMutex);
|
||||
const auto &it = m_surfaces.find(surfaceId);
|
||||
if (it != m_surfaces.end())
|
||||
m_surfaces.erase(it);
|
||||
}
|
||||
|
||||
env->CallStaticVoidMethod(m_applicationClass,
|
||||
QJNIEnvironmentPrivate env;
|
||||
if (env)
|
||||
env->CallStaticVoidMethod(m_applicationClass,
|
||||
m_destroySurfaceMethodID,
|
||||
surfaceId);
|
||||
}
|
||||
@ -584,18 +589,12 @@ static void setSurface(JNIEnv *env, jobject /*thiz*/, jint id, jobject jSurface,
|
||||
{
|
||||
QMutexLocker lock(&m_surfacesMutex);
|
||||
const auto &it = m_surfaces.find(id);
|
||||
if (it == m_surfaces.end()) {
|
||||
qWarning()<<"Can't find surface" << id;
|
||||
if (it == m_surfaces.end())
|
||||
return;
|
||||
}
|
||||
|
||||
auto surfaceClient = it.value();
|
||||
if (!surfaceClient) // This should never happen...
|
||||
return;
|
||||
|
||||
surfaceClient->surfaceChanged(env, jSurface, w, h);
|
||||
|
||||
if (!jSurface)
|
||||
m_surfaces.erase(it);
|
||||
if (surfaceClient)
|
||||
surfaceClient->surfaceChanged(env, jSurface, w, h);
|
||||
}
|
||||
|
||||
static void setDisplayMetrics(JNIEnv */*env*/, jclass /*clazz*/,
|
||||
|
@ -311,10 +311,13 @@ void QAndroidPlatformScreen::doRedraw()
|
||||
}
|
||||
}
|
||||
if (!hasVisibleRasterWindows) {
|
||||
lockSurface();
|
||||
if (m_id != -1) {
|
||||
QtAndroid::destroySurface(m_id);
|
||||
releaseSurface();
|
||||
m_id = -1;
|
||||
}
|
||||
unlockSurface();
|
||||
return;
|
||||
}
|
||||
QMutexLocker lock(&m_surfaceMutex);
|
||||
|
Loading…
Reference in New Issue
Block a user