From 94f1b85cf7e3f8983779a09b55cd22a47ab9203a Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 26 Nov 2013 13:09:42 +0100 Subject: Check the thread in QOffscreenSurface The QWindow-based fallback will not work when the QOffscreenSurface is created outside the main thread. Show a warning in this case. Note that it is fine to use the QOffscreenSurface instance in another thread. It is just the creation that must happen on the main thread. Change-Id: If80da39e610813755b9ba2f6831b187b258b8266 Reviewed-by: Yoann Lopes Reviewed-by: Gunnar Sletta --- src/gui/kernel/qoffscreensurface.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/gui/kernel/qoffscreensurface.cpp b/src/gui/kernel/qoffscreensurface.cpp index e2306050dd..ce913a98af 100644 --- a/src/gui/kernel/qoffscreensurface.cpp +++ b/src/gui/kernel/qoffscreensurface.cpp @@ -160,6 +160,8 @@ void QOffscreenSurface::create() d->platformOffscreenSurface = QGuiApplicationPrivate::platformIntegration()->createPlatformOffscreenSurface(this); // No platform offscreen surface, fallback to an invisible window if (!d->platformOffscreenSurface) { + if (QThread::currentThread() != qGuiApp->thread()) + qWarning("Attempting to create QWindow-based QOffscreenSurface outside the gui thread. Expect failures."); d->offscreenWindow = new QWindow(d->screen); d->offscreenWindow->setSurfaceType(QWindow::OpenGLSurface); d->offscreenWindow->setFormat(d->requestedFormat); -- cgit v1.2.3