summaryrefslogtreecommitdiffstats
path: root/src/Viewer
diff options
context:
space:
mode:
authorAntti Määttä <antti.maatta@qt.io>2019-04-24 15:15:12 +0300
committerAntti Määttä <antti.maatta@qt.io>2019-04-24 13:00:23 +0000
commit21fa0acd255e5e55dad0ffc1fc6553e739c3276c (patch)
tree506c8b9bd6e41f82dbcc14fd0a6bf130853c5dd7 /src/Viewer
parent01c856feea3eb1d3265e4e900d830e39df4a38b8 (diff)
Fix crash in editor when using qml stream
The crash occurs due to stack overflow due to recursive subpresentation initialization in runtime codes. This happens because the qml subpresentation has the same id as the presentation filename, which is assigned to default initial id from the presentation filename. When the layer, which is using the qml subpresentation, is initialized in the runtime, it gets the uip presentation instead of the qml subpresentation. The same begins to happen recursively. Add the ability to change the initial presentation id from the surface viewer api, which is used to render the subpresentations in the editor so that it gets valid id instead of the id from filename. Task-number: QT3DS-3345 Change-Id: I45f3a8ce9b5dc030f120baa1a8aed6c284ea7e3c Reviewed-by: Jere Tuliniemi <jere.tuliniemi@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Diffstat (limited to 'src/Viewer')
-rw-r--r--src/Viewer/studio3d/q3dssurfaceviewer.cpp17
-rw-r--r--src/Viewer/studio3d/q3dssurfaceviewer.h4
-rw-r--r--src/Viewer/studio3d/q3dssurfaceviewer_p.h1
3 files changed, 22 insertions, 0 deletions
diff --git a/src/Viewer/studio3d/q3dssurfaceviewer.cpp b/src/Viewer/studio3d/q3dssurfaceviewer.cpp
index f477723b..c64ecbfc 100644
--- a/src/Viewer/studio3d/q3dssurfaceviewer.cpp
+++ b/src/Viewer/studio3d/q3dssurfaceviewer.cpp
@@ -121,6 +121,11 @@ bool Q3DSSurfaceViewer::isRunning() const
return d_ptr->m_viewerApp != nullptr;
}
+QString Q3DSSurfaceViewer::presentationId() const
+{
+ return d_ptr->m_id;
+}
+
int Q3DSSurfaceViewer::fboId() const
{
return d_ptr->m_fboId;
@@ -146,6 +151,16 @@ Q3DSPresentation *Q3DSSurfaceViewer::presentation() const
return d_ptr->m_presentation;
}
+void Q3DSSurfaceViewer::setPresentationId(const QString &id)
+{
+ if (d_ptr->m_id != id) {
+ d_ptr->m_id = id;
+ Q_EMIT presentationIdChanged(id);
+ if (d_ptr->m_viewerApp)
+ d_ptr->m_viewerApp->setPresentationId(id);
+ }
+}
+
Q3DSSurfaceViewerPrivate::Q3DSSurfaceViewerPrivate(Q3DSSurfaceViewer *q)
: QObject(q)
, q_ptr(q)
@@ -159,6 +174,7 @@ Q3DSSurfaceViewerPrivate::Q3DSSurfaceViewerPrivate(Q3DSSurfaceViewer *q)
, m_autoSize(true)
, m_settings(new Q3DSViewerSettings(this))
, m_presentation(new Q3DSPresentation(this))
+ , m_id(QStringLiteral("initial"))
{
connect(m_presentation, &Q3DSPresentation::sourceChanged,
this, &Q3DSSurfaceViewerPrivate::reset);
@@ -362,6 +378,7 @@ bool Q3DSSurfaceViewerPrivate::initializeRuntime()
return false;
}
+ m_viewerApp->setPresentationId(m_id);
m_settings->d_ptr->setViewerApp(m_viewerApp);
m_presentation->d_ptr->setViewerApp(m_viewerApp);
diff --git a/src/Viewer/studio3d/q3dssurfaceviewer.h b/src/Viewer/studio3d/q3dssurfaceviewer.h
index 80c6692d..fc99ccaf 100644
--- a/src/Viewer/studio3d/q3dssurfaceviewer.h
+++ b/src/Viewer/studio3d/q3dssurfaceviewer.h
@@ -53,6 +53,7 @@ class Q_STUDIO3D_EXPORT Q3DSSurfaceViewer : public QObject
Q_PROPERTY(bool autoSize READ autoSize WRITE setAutoSize NOTIFY autoSizeChanged)
Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval NOTIFY updateIntervalChanged)
Q_PROPERTY(bool running READ isRunning NOTIFY runningChanged)
+ Q_PROPERTY(QString presentationId READ presentationId WRITE setPresentationId NOTIFY presentationIdChanged)
public:
explicit Q3DSSurfaceViewer(QObject *parent = nullptr);
@@ -67,6 +68,7 @@ public:
bool autoSize() const;
int updateInterval() const;
bool isRunning() const;
+ QString presentationId() const;
int fboId() const;
QSurface *surface() const;
@@ -82,6 +84,7 @@ public Q_SLOTS:
void update();
void shutdown();
void reset();
+ void setPresentationId(const QString &id);
Q_SIGNALS:
void sizeChanged(const QSize &size);
@@ -89,6 +92,7 @@ Q_SIGNALS:
void updateIntervalChanged(bool autoUpdate);
void runningChanged(bool initialized);
void frameUpdated();
+ void presentationIdChanged(const QString &id);
private:
Q_DISABLE_COPY(Q3DSSurfaceViewer)
diff --git a/src/Viewer/studio3d/q3dssurfaceviewer_p.h b/src/Viewer/studio3d/q3dssurfaceviewer_p.h
index f82e4ba3..a668513e 100644
--- a/src/Viewer/studio3d/q3dssurfaceviewer_p.h
+++ b/src/Viewer/studio3d/q3dssurfaceviewer_p.h
@@ -94,6 +94,7 @@ private:
bool m_autoSize;
Q3DSViewerSettings *m_settings;
Q3DSPresentation *m_presentation;
+ QString m_id;
};
QT_END_NAMESPACE