summaryrefslogtreecommitdiffstats
path: root/src/Viewer/studio3d/q3dssurfaceviewer.cpp
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/studio3d/q3dssurfaceviewer.cpp
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/studio3d/q3dssurfaceviewer.cpp')
-rw-r--r--src/Viewer/studio3d/q3dssurfaceviewer.cpp17
1 files changed, 17 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);