Android: don't rely on implicit cast of declared QtJniTypes to jobject
The operator jobject() should be removed from declared QtJniTypes in qtbase, as it's dangerous. Prepare for that by calling object(), which returns the wrapped jobject as well, or isValid() where previously the implicit conversion to jobject also enabled implicit conversion to bool. Change-Id: I00cf6f1463dd5ab5cbaf03d9e77bfff3bced9b15 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit is contained in:
parent
703614f03b
commit
8c9f5fba03
@ -68,7 +68,7 @@ QtJniTypes::Context QNativeInterface::QAndroidApplication::context()
|
|||||||
*/
|
*/
|
||||||
bool QNativeInterface::QAndroidApplication::isActivityContext()
|
bool QNativeInterface::QAndroidApplication::isActivityContext()
|
||||||
{
|
{
|
||||||
return QtAndroidPrivate::activity();
|
return QtAndroidPrivate::activity().isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -484,7 +484,7 @@ static void waitForServiceSetup(JNIEnv *env, jclass /*clazz*/)
|
|||||||
Q_UNUSED(env);
|
Q_UNUSED(env);
|
||||||
// The service must wait until the QCoreApplication starts otherwise onBind will be
|
// The service must wait until the QCoreApplication starts otherwise onBind will be
|
||||||
// called too early
|
// called too early
|
||||||
if (QtAndroidPrivate::service())
|
if (QtAndroidPrivate::service().isValid())
|
||||||
QtAndroidPrivate::waitForServiceSetup();
|
QtAndroidPrivate::waitForServiceSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ static jclass g_messageDialogHelperClass = nullptr;
|
|||||||
|
|
||||||
QAndroidPlatformMessageDialogHelper::QAndroidPlatformMessageDialogHelper()
|
QAndroidPlatformMessageDialogHelper::QAndroidPlatformMessageDialogHelper()
|
||||||
: m_javaMessageDialog(g_messageDialogHelperClass, "(Landroid/app/Activity;)V",
|
: m_javaMessageDialog(g_messageDialogHelperClass, "(Landroid/app/Activity;)V",
|
||||||
static_cast<jobject>(QtAndroidPrivate::activity()))
|
QtAndroidPrivate::activity().object())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,11 +320,11 @@ bool QAndroidPlatformIntegration::hasCapability(Capability cap) const
|
|||||||
switch (cap) {
|
switch (cap) {
|
||||||
case ApplicationState: return true;
|
case ApplicationState: return true;
|
||||||
case ThreadedPixmaps: return true;
|
case ThreadedPixmaps: return true;
|
||||||
case NativeWidgets: return QtAndroidPrivate::activity();
|
case NativeWidgets: return QtAndroidPrivate::activity().isValid();
|
||||||
case OpenGL: return QtAndroidPrivate::activity();
|
case OpenGL: return QtAndroidPrivate::activity().isValid();
|
||||||
case ForeignWindows: return QtAndroidPrivate::activity();
|
case ForeignWindows: return QtAndroidPrivate::activity().isValid();
|
||||||
case ThreadedOpenGL: return !needsBasicRenderloopWorkaround() && QtAndroidPrivate::activity();
|
case ThreadedOpenGL: return !needsBasicRenderloopWorkaround() && QtAndroidPrivate::activity().isValid();
|
||||||
case RasterGLSurface: return QtAndroidPrivate::activity();
|
case RasterGLSurface: return QtAndroidPrivate::activity().isValid();
|
||||||
case TopStackedNativeChildWindows: return false;
|
case TopStackedNativeChildWindows: return false;
|
||||||
case MaximizeUsingFullscreenGeometry: return true;
|
case MaximizeUsingFullscreenGeometry: return true;
|
||||||
default:
|
default:
|
||||||
@ -334,7 +334,7 @@ bool QAndroidPlatformIntegration::hasCapability(Capability cap) const
|
|||||||
|
|
||||||
QPlatformBackingStore *QAndroidPlatformIntegration::createPlatformBackingStore(QWindow *window) const
|
QPlatformBackingStore *QAndroidPlatformIntegration::createPlatformBackingStore(QWindow *window) const
|
||||||
{
|
{
|
||||||
if (!QtAndroidPrivate::activity())
|
if (!QtAndroidPrivate::activity().isValid())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return new QAndroidPlatformBackingStore(window);
|
return new QAndroidPlatformBackingStore(window);
|
||||||
@ -342,7 +342,7 @@ QPlatformBackingStore *QAndroidPlatformIntegration::createPlatformBackingStore(Q
|
|||||||
|
|
||||||
QPlatformOpenGLContext *QAndroidPlatformIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
|
QPlatformOpenGLContext *QAndroidPlatformIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
|
||||||
{
|
{
|
||||||
if (!QtAndroidPrivate::activity())
|
if (!QtAndroidPrivate::activity().isValid())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
QSurfaceFormat format(context->format());
|
QSurfaceFormat format(context->format());
|
||||||
format.setAlphaBufferSize(8);
|
format.setAlphaBufferSize(8);
|
||||||
@ -360,7 +360,7 @@ QOpenGLContext *QAndroidPlatformIntegration::createOpenGLContext(EGLContext cont
|
|||||||
|
|
||||||
QPlatformOffscreenSurface *QAndroidPlatformIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const
|
QPlatformOffscreenSurface *QAndroidPlatformIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const
|
||||||
{
|
{
|
||||||
if (!QtAndroidPrivate::activity())
|
if (!QtAndroidPrivate::activity().isValid())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
QSurfaceFormat format(surface->requestedFormat());
|
QSurfaceFormat format(surface->requestedFormat());
|
||||||
@ -374,7 +374,7 @@ QPlatformOffscreenSurface *QAndroidPlatformIntegration::createPlatformOffscreenS
|
|||||||
|
|
||||||
QOffscreenSurface *QAndroidPlatformIntegration::createOffscreenSurface(ANativeWindow *nativeSurface) const
|
QOffscreenSurface *QAndroidPlatformIntegration::createOffscreenSurface(ANativeWindow *nativeSurface) const
|
||||||
{
|
{
|
||||||
if (!QtAndroidPrivate::activity() || !nativeSurface)
|
if (!QtAndroidPrivate::activity().isValid() || !nativeSurface)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
auto *surface = new QOffscreenSurface;
|
auto *surface = new QOffscreenSurface;
|
||||||
@ -385,7 +385,7 @@ QOffscreenSurface *QAndroidPlatformIntegration::createOffscreenSurface(ANativeWi
|
|||||||
|
|
||||||
QPlatformWindow *QAndroidPlatformIntegration::createPlatformWindow(QWindow *window) const
|
QPlatformWindow *QAndroidPlatformIntegration::createPlatformWindow(QWindow *window) const
|
||||||
{
|
{
|
||||||
if (!QtAndroidPrivate::activity())
|
if (!QtAndroidPrivate::activity().isValid())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
#if QT_CONFIG(vulkan)
|
#if QT_CONFIG(vulkan)
|
||||||
|
@ -368,7 +368,7 @@ int QAndroidPlatformScreen::rasterSurfaces()
|
|||||||
void QAndroidPlatformScreen::doRedraw(QImage* screenGrabImage)
|
void QAndroidPlatformScreen::doRedraw(QImage* screenGrabImage)
|
||||||
{
|
{
|
||||||
PROFILE_SCOPE;
|
PROFILE_SCOPE;
|
||||||
if (!QtAndroidPrivate::activity())
|
if (!QtAndroidPrivate::activity().isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_dirtyRect.isEmpty())
|
if (m_dirtyRect.isEmpty())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user