Android: Guard against invalid surfaceID
Do not try to resize or destroy invalid surfaces. This caused update problems with all GL apps after suspend, since we would forget the dummy view that we always keep around so we get proper transitions on shutdown. Also make sure that we don't mess this up even if we try to destroy a non-existing surface. This would have fixed the bug by itself, but then we would still be stuck with the annoying warning message. Task-number: QTBUG-41093 Change-Id: I83299e93eb9ac5357b98ca47014789b56c91b35a Reviewed-by: Christian Stromme <christian.stromme@digia.com>
This commit is contained in:
parent
a8b243b42e
commit
d450eb5e6d
@ -1085,11 +1085,14 @@ public class QtActivityDelegate
|
|||||||
Log.e(QtNative.QtTAG, "Surface " + id +" not found!");
|
Log.e(QtNative.QtTAG, "Surface " + id +" not found!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (view == null)
|
||||||
|
return;
|
||||||
|
|
||||||
// Keep last frame in stack until it is replaced to get correct
|
// Keep last frame in stack until it is replaced to get correct
|
||||||
// shutdown transition
|
// shutdown transition
|
||||||
if (m_surfaces.size() == 0 && m_nativeViews.size() == 0) {
|
if (m_surfaces.size() == 0 && m_nativeViews.size() == 0) {
|
||||||
m_dummyView = view;
|
m_dummyView = view;
|
||||||
} else if (view != null) {
|
} else {
|
||||||
m_layout.removeView(view);
|
m_layout.removeView(view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -380,6 +380,9 @@ namespace QtAndroid
|
|||||||
|
|
||||||
void setSurfaceGeometry(int surfaceId, const QRect &geometry)
|
void setSurfaceGeometry(int surfaceId, const QRect &geometry)
|
||||||
{
|
{
|
||||||
|
if (surfaceId == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
QJNIEnvironmentPrivate env;
|
QJNIEnvironmentPrivate env;
|
||||||
if (!env)
|
if (!env)
|
||||||
return;
|
return;
|
||||||
@ -399,6 +402,9 @@ namespace QtAndroid
|
|||||||
|
|
||||||
void destroySurface(int surfaceId)
|
void destroySurface(int surfaceId)
|
||||||
{
|
{
|
||||||
|
if (surfaceId == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
QMutexLocker lock(&m_surfacesMutex);
|
QMutexLocker lock(&m_surfacesMutex);
|
||||||
const auto &it = m_surfaces.find(surfaceId);
|
const auto &it = m_surfaces.find(surfaceId);
|
||||||
if (it != m_surfaces.end())
|
if (it != m_surfaces.end())
|
||||||
|
Loading…
Reference in New Issue
Block a user