diff options
author | Paul Olav Tvete <paul.tvete@qt.io> | 2016-09-15 12:31:45 +0200 |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@qt.io> | 2016-09-18 07:02:28 +0000 |
commit | 99b82a05bec352672d984a5e4a1210d46ebf007d (patch) | |
tree | aaad585b641aba04669d2da84c26dbb8485023a5 | |
parent | 02e34ece17ca1b24111ccb5110bfdb0c740f8923 (diff) | |
download | qtwayland-99b82a05bec352672d984a5e4a1210d46ebf007d.tar.gz |
Cleanup and null ptr check
Don't crash if we ask for the surface before the window is created.
Also clean up NULL/0/nullptr and a c-style cast.
Change-Id: I2a5a66ee76a3a12c8ca32847dbe30cc640e924c2
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@hawaiios.org>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
-rw-r--r-- | src/client/qwaylandnativeinterface.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/client/qwaylandnativeinterface.cpp b/src/client/qwaylandnativeinterface.cpp index be639ce1..4a79fb5a 100644 --- a/src/client/qwaylandnativeinterface.cpp +++ b/src/client/qwaylandnativeinterface.cpp @@ -76,7 +76,7 @@ void *QWaylandNativeInterface::nativeResourceForIntegration(const QByteArray &re if (lowerCaseResource == "egldisplay" && m_integration->clientBufferIntegration()) return m_integration->clientBufferIntegration()->nativeResource(QWaylandClientBufferIntegration::EglDisplay); - return 0; + return nullptr; } void *QWaylandNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) @@ -88,21 +88,22 @@ void *QWaylandNativeInterface::nativeResourceForWindow(const QByteArray &resourc if (lowerCaseResource == "compositor") return const_cast<wl_compositor *>(m_integration->display()->wl_compositor()); if (lowerCaseResource == "surface") { - return ((QWaylandWindow *) window->handle())->object(); + QWaylandWindow *w = static_cast<QWaylandWindow*>(window->handle()); + return w ? w->object() : nullptr; } if (lowerCaseResource == "wl_shell_surface") { - QWaylandWindow *w = (QWaylandWindow *) window->handle(); + QWaylandWindow *w = static_cast<QWaylandWindow*>(window->handle()); if (!w) - return NULL; + return nullptr; QWaylandWlShellSurface *s = qobject_cast<QWaylandWlShellSurface *>(w->shellSurface()); if (!s) - return NULL; + return nullptr; return s->object(); } if (lowerCaseResource == "egldisplay" && m_integration->clientBufferIntegration()) return m_integration->clientBufferIntegration()->nativeResource(QWaylandClientBufferIntegration::EglDisplay); - return NULL; + return nullptr; } void *QWaylandNativeInterface::nativeResourceForScreen(const QByteArray &resourceString, QScreen *screen) @@ -112,7 +113,7 @@ void *QWaylandNativeInterface::nativeResourceForScreen(const QByteArray &resourc if (lowerCaseResource == "output") return ((QWaylandScreen *) screen->handle())->output(); - return NULL; + return nullptr; } void *QWaylandNativeInterface::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) @@ -130,7 +131,7 @@ void *QWaylandNativeInterface::nativeResourceForContext(const QByteArray &resour return m_integration->clientBufferIntegration()->nativeResourceForContext(QWaylandClientBufferIntegration::EglDisplay, context->handle()); #endif - return 0; + return nullptr; } QVariantMap QWaylandNativeInterface::windowProperties(QPlatformWindow *window) const @@ -171,7 +172,7 @@ QFunctionPointer QWaylandNativeInterface::platformFunction(const QByteArray &res } else if (resource == QWaylandWindowFunctions::isSyncIdentifier()) { return QFunctionPointer(isSync); } - return 0; + return nullptr; } |