From 5dcfc1ced20483a14abbf5f3b04676603fec82fa Mon Sep 17 00:00:00 2001 From: Jari Karppinen Date: Tue, 28 May 2019 16:11:09 +0300 Subject: Remove extra reset method in SurfaceViewer API Keep reset in the private implementation to properly handle sourceChanged. Rename shutdown to destroy to harmonize with RT2. Task-number: QT3DS-3535 Change-Id: Ib80f5455430b1586170c77f95a8aa6521a3769d8 Reviewed-by: Miikka Heikkinen --- src/Runtime/api/studio3d/q3dssurfaceviewer.cpp | 42 +++++++++++--------------- src/Runtime/api/studio3d/q3dssurfaceviewer.h | 3 -- src/Runtime/api/studio3d/q3dssurfaceviewer_p.h | 4 +-- 3 files changed, 19 insertions(+), 30 deletions(-) diff --git a/src/Runtime/api/studio3d/q3dssurfaceviewer.cpp b/src/Runtime/api/studio3d/q3dssurfaceviewer.cpp index bd0fd6aa..23782f2f 100644 --- a/src/Runtime/api/studio3d/q3dssurfaceviewer.cpp +++ b/src/Runtime/api/studio3d/q3dssurfaceviewer.cpp @@ -156,15 +156,7 @@ bool Q3DSSurfaceViewer::create(QSurface *surface, QOpenGLContext *context, GLuin */ void Q3DSSurfaceViewer::destroy() { - d_ptr->shutdown(); -} - -/*! - \brief Q3DSSurfaceViewer::reset - */ -void Q3DSSurfaceViewer::reset() -{ - d_ptr->reset(); + d_ptr->destroy(); } /*! @@ -411,17 +403,6 @@ Q3DSSurfaceViewerPrivate::~Q3DSSurfaceViewerPrivate() delete m_timer; } -/*! - * \internal - */ -void Q3DSSurfaceViewerPrivate::reset() -{ - if (m_viewerApp) { - releaseRuntime(); - initializeRuntime(); - } -} - /*! * \internal */ @@ -473,7 +454,7 @@ bool Q3DSSurfaceViewerPrivate::initialize(QSurface *surface, QOpenGLContext *con return false; } - shutdown(); + destroy(); m_surface = surface; m_context = context; @@ -483,7 +464,7 @@ bool Q3DSSurfaceViewerPrivate::initialize(QSurface *surface, QOpenGLContext *con surfaceObject()->installEventFilter(this); - connect(context, &QOpenGLContext::aboutToBeDestroyed, this, &Q3DSSurfaceViewerPrivate::shutdown); + connect(context, &QOpenGLContext::aboutToBeDestroyed, this, &Q3DSSurfaceViewerPrivate::destroy); bool success = initializeRuntime(); @@ -496,13 +477,13 @@ bool Q3DSSurfaceViewerPrivate::initialize(QSurface *surface, QOpenGLContext *con /*! * \internal */ -void Q3DSSurfaceViewerPrivate::shutdown() +void Q3DSSurfaceViewerPrivate::destroy() { bool oldInitialized = (m_viewerApp != nullptr); if (m_context) { disconnect(m_context, &QOpenGLContext::aboutToBeDestroyed, - this, &Q3DSSurfaceViewerPrivate::shutdown); + this, &Q3DSSurfaceViewerPrivate::destroy); } if (m_surface) @@ -593,12 +574,23 @@ bool Q3DSSurfaceViewerPrivate::eventFilter(QObject *obj, QEvent *e) if (surfaceObject() == obj) { QPlatformSurfaceEvent *ev = static_cast(e); if (ev->surfaceEventType() == QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed) - shutdown(); + destroy(); } } return QObject::eventFilter(obj, e); } +/*! + * \internal + */ +void Q3DSSurfaceViewerPrivate::reset() +{ + if (m_viewerApp) { + releaseRuntime(); + initializeRuntime(); + } +} + /*! * \internal */ diff --git a/src/Runtime/api/studio3d/q3dssurfaceviewer.h b/src/Runtime/api/studio3d/q3dssurfaceviewer.h index 75e35713..5c166af9 100644 --- a/src/Runtime/api/studio3d/q3dssurfaceviewer.h +++ b/src/Runtime/api/studio3d/q3dssurfaceviewer.h @@ -91,11 +91,8 @@ public: void setQmlEngine(QQmlEngine *qmlEngine); QString presentationId() const; - - public Q_SLOTS: void update(); - void reset(); void setPresentationId(const QString &id); Q_SIGNALS: diff --git a/src/Runtime/api/studio3d/q3dssurfaceviewer_p.h b/src/Runtime/api/studio3d/q3dssurfaceviewer_p.h index 656d139c..fc6b4cc8 100644 --- a/src/Runtime/api/studio3d/q3dssurfaceviewer_p.h +++ b/src/Runtime/api/studio3d/q3dssurfaceviewer_p.h @@ -62,7 +62,6 @@ public: explicit Q3DSSurfaceViewerPrivate(Q3DSSurfaceViewer *parent = nullptr); ~Q3DSSurfaceViewerPrivate(); - void reset(); void setSize(const QSize &size); void setUpdateInterval(int interval); bool initialize(QSurface *surface, QOpenGLContext *context, GLuint fboId); @@ -71,12 +70,13 @@ public: QImage grab(const QRect &rect); private Q_SLOTS: - void shutdown(); + void destroy(); protected: bool eventFilter(QObject *obj, QEvent *e) override; private: + void reset(); bool initializeRuntime(); void releaseRuntime(); void resetUpdateTimer(); -- cgit v1.2.3