From b8afc009afcca84a3fd3d5617dfe96c729c531aa Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 10 Mar 2014 10:53:49 +0100 Subject: Consolidate context creation failure handling in Quick. Add QQuickWidget::sceneGraphError() equivalent to QQuickWindow::sceneGraphError(), move message formatting code to QQuickWindowPrivate. Change-Id: I18cd4d7e0f6ee1011c29375218dc6a044b0d2cf2 Reviewed-by: Laszlo Agocs --- src/quick/items/qquickwindow.cpp | 31 +++++++++++++++++++++++++++++++ src/quick/items/qquickwindow_p.h | 5 +++++ 2 files changed, 36 insertions(+) (limited to 'src/quick/items') diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index d7a6f071c6..6a56a5dc82 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -65,6 +65,7 @@ #include #include #include +#include #include #include @@ -2303,6 +2304,36 @@ bool QQuickWindowPrivate::isRenderable() const return ((q->isExposed() && q->isVisible())) && q->geometry().isValid(); } +void QQuickWindowPrivate::contextCreationFailureMessage(const QSurfaceFormat &format, + QString *translatedMessage, + QString *untranslatedMessage, + bool isEs) +{ + const QString contextType = QLatin1String(isEs ? "EGL" : "OpenGL"); + QString formatStr; + QDebug(&formatStr) << format; +#if defined(Q_OS_WIN32) + const bool isDebug = QLibraryInfo::isDebugBuild(); + const QString eglLibName = QLatin1String(isDebug ? "libEGLd.dll" : "libEGL.dll"); + const QString glesLibName = QLatin1String(isDebug ? "libGLESv2d.dll" : "libGLESv2.dll"); + //: %1 Context type (Open GL, EGL), ANGLE %2, %3 library names + const char msg[] = QT_TRANSLATE_NOOP("QQuickWindow", + "Failed to create %1 context for format %2." + "This is most likely caused by not having the necessary graphics drivers installed.\n\n" + "Install a driver providing OpenGL 2.0 or higher, or, if this is not possible, " + "make sure the ANGLE Open GL ES 2.0 emulation libraries (%3, %4 and d3dcompiler_*.dll) " + "are available in the application executable's directory or in a location listed in PATH."); + *translatedMessage = QQuickWindow::tr(msg).arg(contextType, formatStr, eglLibName, glesLibName); + *untranslatedMessage = QString::fromLatin1(msg).arg(contextType, formatStr, eglLibName, glesLibName); +#else // Q_OS_WIN32 + //: %1 Context type (Open GL, EGL), %2 format specification + const char msg[] = QT_TRANSLATE_NOOP("QQuickWindow", + "Failed to create %1 context for format %2"); + *translatedMessage = QQuickWindow::tr(msg).arg(contextType, formatStr); + *untranslatedMessage = QString::fromLatin1(msg).arg(contextType, formatStr); +#endif // !Q_OS_WIN32 +} + /*! Propagates an event \a e to a QQuickItem \a item on the window. diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h index e78f00c22f..421651b483 100644 --- a/src/quick/items/qquickwindow_p.h +++ b/src/quick/items/qquickwindow_p.h @@ -242,6 +242,11 @@ public: static QObject *data_at(QQmlListProperty *, int); static void data_clear(QQmlListProperty *); + static void contextCreationFailureMessage(const QSurfaceFormat &format, + QString *translatedMessage, + QString *untranslatedMessage, + bool isEs); + private: static void cleanupNodesOnShutdown(QQuickItem *); }; -- cgit v1.2.3