diff options
author | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-02-20 16:14:45 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-21 16:29:07 +0100 |
commit | bbf1ec42e5875a6e8145211348e509690a30d0a5 (patch) | |
tree | b2a50ccea52dcff9bb5e13e3ffad914eed45ff2f /src/quick/scenegraph/qsgrenderloop.cpp | |
parent | 3eb56ecb7776fa106d1fb6e43355e2c1bf5c1d0c (diff) |
Add an error signal to QQuickWindow
When nothing is connected to this signal, an error will be printed or,
in case of Windows, a message box will be shown. If there is something
connected, it is up to the application to handle the error.
[ChangeLog] Added a new sceneGraphError() signal to QQuickWindow
which applications can use to detect errors like OpenGL context creation
failures and react in their own custom ways.
Task-number: QTBUG-36138
Change-Id: I33b1e5e0e3f25872af67c5bb5ae937e3470b25f3
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/quick/scenegraph/qsgrenderloop.cpp')
-rw-r--r-- | src/quick/scenegraph/qsgrenderloop.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index 50c5b141c3..08ab3809b3 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -281,9 +281,18 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) if (QSGContext::sharedOpenGLContext()) gl->setShareContext(QSGContext::sharedOpenGLContext()); if (!gl->create()) { - qWarning("QtQuick: failed to create OpenGL context"); delete gl; gl = 0; + QString formatStr; + QDebug(&formatStr) << window->requestedFormat(); + QString contextType = QLatin1String(QOpenGLFunctions::isES() ? "EGL" : "OpenGL"); + const char *msg = QT_TRANSLATE_NOOP("QSGGuiThreadRenderLoop", "Failed to create %1 context for format %2"); + QString translatedMsg = tr(msg).arg(contextType).arg(formatStr); + QString nonTranslatedMsg = QString(QLatin1String(msg)).arg(contextType).arg(formatStr); + bool signalEmitted = QQuickWindowPrivate::get(window)->emitError(QQuickWindow::ContextNotAvailable, + translatedMsg); + if (!signalEmitted) + qFatal("%s", qPrintable(nonTranslatedMsg)); } else { current = gl->makeCurrent(window); } |