diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2013-02-24 09:14:20 -0800 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-26 22:01:27 +0100 |
commit | 1b76cf017427a98bf4487f3cf576611d82097539 (patch) | |
tree | f7348ce5e47854ea1e608a873b19b4c6889e5a41 /src/plugins/platforms/eglfs/qeglfsintegration.cpp | |
parent | bc5170f274572a4b262569c12d5d3c6ef892aaf2 (diff) |
EGLFS: Replace the global static 'hooks' variable with a function
Having a global static variable in a header is a poor choice to start
with. All .cpp including that header must use that variable or the
compiler will warn of an unused static.
Second, for the case of platform hooks, it's possible that it is reading
the value of a variable that isn't initialised yet.
Change-Id: Id823c2be9cfededb9c31fb76a9080d4122577ca4
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'src/plugins/platforms/eglfs/qeglfsintegration.cpp')
-rw-r--r-- | src/plugins/platforms/eglfs/qeglfsintegration.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp index dd212c80a0..0fc4c44629 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp @@ -83,7 +83,7 @@ QEglFSIntegration::QEglFSIntegration() new QEvdevTouchScreenHandlerThread(QString() /* spec */, this); #endif - hooks->platformInit(); + QEglFSHooks::hooks()->platformInit(); EGLint major, minor; @@ -92,7 +92,7 @@ QEglFSIntegration::QEglFSIntegration() qFatal("EGL error"); } - mDisplay = eglGetDisplay(hooks ? hooks->platformDisplay() : EGL_DEFAULT_DISPLAY); + mDisplay = eglGetDisplay(QEglFSHooks::hooks() ? QEglFSHooks::hooks()->platformDisplay() : EGL_DEFAULT_DISPLAY); if (mDisplay == EGL_NO_DISPLAY) { qWarning("Could not open egl display\n"); qFatal("EGL error"); @@ -122,13 +122,13 @@ QEglFSIntegration::~QEglFSIntegration() delete mScreen; eglTerminate(mDisplay); - hooks->platformDestroy(); + QEglFSHooks::hooks()->platformDestroy(); } bool QEglFSIntegration::hasCapability(QPlatformIntegration::Capability cap) const { // We assume that devices will have more and not less capabilities - if (hooks && hooks->hasCapability(cap)) + if (QEglFSHooks::hooks() && QEglFSHooks::hooks()->hasCapability(cap)) return true; switch (cap) { @@ -153,13 +153,13 @@ QPlatformBackingStore *QEglFSIntegration::createPlatformBackingStore(QWindow *wi QPlatformOpenGLContext *QEglFSIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const { - return new QEglFSContext(hooks->surfaceFormatFor(context->format()), context->shareHandle(), mDisplay); + return new QEglFSContext(QEglFSHooks::hooks()->surfaceFormatFor(context->format()), context->shareHandle(), mDisplay); } QPlatformOffscreenSurface *QEglFSIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const { QEglFSScreen *screen = static_cast<QEglFSScreen *>(surface->screen()->handle()); - return new QEGLPbuffer(screen->display(), hooks->surfaceFormatFor(surface->requestedFormat()), surface); + return new QEGLPbuffer(screen->display(), QEglFSHooks::hooks()->surfaceFormatFor(surface->requestedFormat()), surface); } QPlatformFontDatabase *QEglFSIntegration::fontDatabase() const @@ -230,7 +230,7 @@ EGLConfig QEglFSIntegration::chooseConfig(EGLDisplay display, const QSurfaceForm QEglFSHooks *m_hooks; }; - Chooser chooser(display, hooks); + Chooser chooser(display, QEglFSHooks::hooks()); chooser.setSurfaceFormat(format); return chooser.chooseConfig(); } |