summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJari Karppinen <jari.karppinen@qt.io>2019-05-28 16:11:09 +0300
committerJari Karppinen <jari.karppinen@qt.io>2019-05-29 13:57:27 +0300
commit5dcfc1ced20483a14abbf5f3b04676603fec82fa (patch)
treed4bd295284dca4ef3e0ee8abe8b78c3d82b85d0e
parenta9e4c6fd641d3fecaecb202f03ad2c223d8f4c2b (diff)
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 <miikka.heikkinen@qt.io>
-rw-r--r--src/Runtime/api/studio3d/q3dssurfaceviewer.cpp42
-rw-r--r--src/Runtime/api/studio3d/q3dssurfaceviewer.h3
-rw-r--r--src/Runtime/api/studio3d/q3dssurfaceviewer_p.h4
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();
}
/*!
@@ -414,17 +406,6 @@ Q3DSSurfaceViewerPrivate::~Q3DSSurfaceViewerPrivate()
/*!
* \internal
*/
-void Q3DSSurfaceViewerPrivate::reset()
-{
- if (m_viewerApp) {
- releaseRuntime();
- initializeRuntime();
- }
-}
-
-/*!
- * \internal
- */
void Q3DSSurfaceViewerPrivate::setSize(const QSize &size)
{
if (m_size != size) {
@@ -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,7 +574,7 @@ bool Q3DSSurfaceViewerPrivate::eventFilter(QObject *obj, QEvent *e)
if (surfaceObject() == obj) {
QPlatformSurfaceEvent *ev = static_cast<QPlatformSurfaceEvent *>(e);
if (ev->surfaceEventType() == QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed)
- shutdown();
+ destroy();
}
}
return QObject::eventFilter(obj, e);
@@ -602,6 +583,17 @@ bool Q3DSSurfaceViewerPrivate::eventFilter(QObject *obj, QEvent *e)
/*!
* \internal
*/
+void Q3DSSurfaceViewerPrivate::reset()
+{
+ if (m_viewerApp) {
+ releaseRuntime();
+ initializeRuntime();
+ }
+}
+
+/*!
+ * \internal
+ */
bool Q3DSSurfaceViewerPrivate::initializeRuntime()
{
Q_ASSERT(!m_viewerApp);
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();