diff options
author | Jari Karppinen <jari.karppinen@qt.io> | 2019-05-31 11:15:46 +0300 |
---|---|---|
committer | Jari Karppinen <jari.karppinen@qt.io> | 2019-05-31 17:32:18 +0300 |
commit | 3d2630a0f36dc664a7dde671ae7f660cad77b317 (patch) | |
tree | 73ff7cb671a1db23d88ea1c82a7ad69a3f85eeda | |
parent | d3d583c73018965c418e625e16750eb5e2da556c (diff) |
Add missing error string to SurfaceViewer API
Task-number: QT3DS-3532
Change-Id: Ia2f9f70daf55ac57e71c0941da8c510f1872cff5
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Pasi Keränen <pasi.keranen@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
3 files changed, 31 insertions, 6 deletions
diff --git a/src/Runtime/ogl-runtime/src/api/studio3d/q3dssurfaceviewer.cpp b/src/Runtime/ogl-runtime/src/api/studio3d/q3dssurfaceviewer.cpp index 23782f2f..401c461d 100644 --- a/src/Runtime/ogl-runtime/src/api/studio3d/q3dssurfaceviewer.cpp +++ b/src/Runtime/ogl-runtime/src/api/studio3d/q3dssurfaceviewer.cpp @@ -281,6 +281,14 @@ int Q3DSSurfaceViewer::fboId() const } /*! + Returns the error string. +*/ +QString Q3DSSurfaceViewer::error() const +{ + return d_ptr->m_error; +} + +/*! Returns the surface given in initialization. \sa create() @@ -442,15 +450,15 @@ bool Q3DSSurfaceViewerPrivate::initialize(QSurface *surface, QOpenGLContext *con Q_ASSERT(surface); if (m_presentation->source().isEmpty()) { - qWarning("Failed to initialize Q3DSSurfaceViewer," - " presentation source must be set before calling initialize()"); + setError(QStringLiteral("Failed to initialize Q3DSSurfaceViewer," + " presentation source must be set before calling initialize()")); return false; } QFileInfo info(Q3DSUtils::urlToLocalFileOrQrc(m_presentation->source())); if (!info.exists()) { - qWarning() << "Failed to initialize Q3DSSurfaceViewer, the presentation doesn't exist:" - << m_presentation->source().toString(); + setError(QStringLiteral("Failed to initialize Q3DSSurfaceViewer, the presentation doesn't exist: %1") + .arg(m_presentation->source().toString())); return false; } @@ -594,6 +602,18 @@ void Q3DSSurfaceViewerPrivate::reset() /*! * \internal */ +void Q3DSSurfaceViewerPrivate::setError(const QString &error) +{ + if (m_error != error) { + m_error = error; + qWarning() << error; + Q_EMIT q_ptr->errorChanged(); + } +} + +/*! + * \internal + */ bool Q3DSSurfaceViewerPrivate::initializeRuntime() { Q_ASSERT(!m_viewerApp); @@ -621,6 +641,7 @@ bool Q3DSSurfaceViewerPrivate::initializeRuntime() m_presentation->variantList(), m_presentation->delayedLoading(), m_presentation->d_ptr->streamProxy())) { + setError(m_viewerApp->error()); releaseRuntime(); qWarning("Failed to initialize runtime"); return false; diff --git a/src/Runtime/ogl-runtime/src/api/studio3d/q3dssurfaceviewer.h b/src/Runtime/ogl-runtime/src/api/studio3d/q3dssurfaceviewer.h index 5c166af9..42be5c2c 100644 --- a/src/Runtime/ogl-runtime/src/api/studio3d/q3dssurfaceviewer.h +++ b/src/Runtime/ogl-runtime/src/api/studio3d/q3dssurfaceviewer.h @@ -51,8 +51,7 @@ class Q_STUDIO3D_EXPORT Q3DSSurfaceViewer : public QObject Q_OBJECT Q_DECLARE_PRIVATE(Q3DSSurfaceViewer) - // #TODO: QT3DS-3532 SurfaceViewer API missing error string - //Q_PROPERTY(QString error READ error NOTIFY errorChanged) + Q_PROPERTY(QString error READ error NOTIFY errorChanged) Q_PROPERTY(bool running READ isRunning NOTIFY runningChanged) Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY sizeChanged) Q_PROPERTY(bool autoSize READ autoSize WRITE setAutoSize NOTIFY autoSizeChanged) @@ -91,6 +90,8 @@ public: void setQmlEngine(QQmlEngine *qmlEngine); QString presentationId() const; + QString error() const; + public Q_SLOTS: void update(); void setPresentationId(const QString &id); @@ -99,6 +100,7 @@ Q_SIGNALS: void presentationLoaded(); void presentationReady(); void frameUpdate(); + void errorChanged(); void presentationIdChanged(const QString &id); void sizeChanged(const QSize &size); diff --git a/src/Runtime/ogl-runtime/src/api/studio3d/q3dssurfaceviewer_p.h b/src/Runtime/ogl-runtime/src/api/studio3d/q3dssurfaceviewer_p.h index fc6b4cc8..624a368c 100644 --- a/src/Runtime/ogl-runtime/src/api/studio3d/q3dssurfaceviewer_p.h +++ b/src/Runtime/ogl-runtime/src/api/studio3d/q3dssurfaceviewer_p.h @@ -77,6 +77,7 @@ protected: private: void reset(); + void setError(const QString &error); bool initializeRuntime(); void releaseRuntime(); void resetUpdateTimer(); @@ -98,6 +99,7 @@ private: QString m_id; QElapsedTimer m_startupTimer; QQmlEngine *qmlEngine = nullptr; + QString m_error; }; QT_END_NAMESPACE |