Fix hang on sleep/wakeup
This patch fixes the followings: - call "it.value()" only on valid iterators - destroySurface() doesn't remove the surfaceId from m_surfaces - the surfaceId is removed from m_surfaces when the QtSurface is really destroyed Task-number: QTBUG-59185 Change-Id: Iee37dde16fee16f19906812c55c1f0b0279b033c Reviewed-by: Mathias Hasselmann <mathias.hasselmann@kdab.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
parent
329385a5d5
commit
da4b91e2b2
@ -402,11 +402,6 @@ namespace QtAndroid
|
|||||||
if (surfaceId == -1)
|
if (surfaceId == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QMutexLocker lock(&m_surfacesMutex);
|
|
||||||
const auto &it = m_surfaces.find(surfaceId);
|
|
||||||
if (it != m_surfaces.end())
|
|
||||||
m_surfaces.remove(surfaceId);
|
|
||||||
|
|
||||||
QJNIEnvironmentPrivate env;
|
QJNIEnvironmentPrivate env;
|
||||||
if (!env)
|
if (!env)
|
||||||
return;
|
return;
|
||||||
@ -583,14 +578,18 @@ static void setSurface(JNIEnv *env, jobject /*thiz*/, jint id, jobject jSurface,
|
|||||||
{
|
{
|
||||||
QMutexLocker lock(&m_surfacesMutex);
|
QMutexLocker lock(&m_surfacesMutex);
|
||||||
const auto &it = m_surfaces.find(id);
|
const auto &it = m_surfaces.find(id);
|
||||||
if (it.value() == nullptr) // This should never happen...
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (it == m_surfaces.end()) {
|
if (it == m_surfaces.end()) {
|
||||||
qWarning()<<"Can't find surface" << id;
|
qWarning()<<"Can't find surface" << id;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
it.value()->surfaceChanged(env, jSurface, w, h);
|
auto surfaceClient = it.value();
|
||||||
|
if (!surfaceClient) // This should never happen...
|
||||||
|
return;
|
||||||
|
|
||||||
|
surfaceClient->surfaceChanged(env, jSurface, w, h);
|
||||||
|
|
||||||
|
if (!jSurface)
|
||||||
|
m_surfaces.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setDisplayMetrics(JNIEnv */*env*/, jclass /*clazz*/,
|
static void setDisplayMetrics(JNIEnv */*env*/, jclass /*clazz*/,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user