From 4a81ef40986e3903ad489a9314b1c38cd7542f86 Mon Sep 17 00:00:00 2001 From: Janne Kangas Date: Tue, 7 Jan 2020 09:24:44 +0200 Subject: Fix SceneElement::currentSlideIndex MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes issue of current slide change signals not working from subpresentations. (Does not touch indexing conventions in SceneElement or Presentation.) Task-ID: QT3DS-3015 Change-Id: I74ef95d72efa1fc75674081e242c9f5526decf77 Reviewed-by: Miikka Heikkinen Reviewed-by: Antti Määttä Reviewed-by: Tomi Korpipää --- src/engine/Qt3DSRuntimeView.cpp | 48 ++++++++++++++++++++--------------- src/runtime/Qt3DSComponentManager.cpp | 8 +++++- 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/engine/Qt3DSRuntimeView.cpp b/src/engine/Qt3DSRuntimeView.cpp index ee2a665..fd3be65 100644 --- a/src/engine/Qt3DSRuntimeView.cpp +++ b/src/engine/Qt3DSRuntimeView.cpp @@ -325,26 +325,31 @@ bool CRuntimeView::InitializeGraphics(const QSurfaceFormat &format, bool delayed void CRuntimeView::connectSignals() { - m_Presentation->signalProxy()->moveToThread(QThread::currentThread()); signalProxy()->moveToThread(QThread::currentThread()); - QObject::connect(m_Presentation->signalProxy(), &QPresentationSignalProxy::SigSlideEntered, - signalProxy(), &QRuntimeViewSignalProxy::SigSlideEntered); - QObject::connect(m_Presentation->signalProxy(), &QPresentationSignalProxy::SigSlideExited, - signalProxy(), &QRuntimeViewSignalProxy::SigSlideExited); - QObject::connect(m_Presentation->signalProxy(), &QPresentationSignalProxy::SigCustomSignal, - signalProxy(), &QRuntimeViewSignalProxy::SigCustomSignal); - QObject::connect(m_Presentation->signalProxy(), - &QPresentationSignalProxy::SigPresentationReady, - signalProxy(), &QRuntimeViewSignalProxy::SigPresentationReady); - QObject::connect(m_Presentation->signalProxy(), &QPresentationSignalProxy::SigElementsCreated, - signalProxy(), &QRuntimeViewSignalProxy::SigElementsCreated); - QObject::connect(m_Presentation->signalProxy(), &QPresentationSignalProxy::SigMaterialsCreated, - signalProxy(), &QRuntimeViewSignalProxy::SigMaterialsCreated); - QObject::connect(m_Presentation->signalProxy(), - &QPresentationSignalProxy::SigDataOutputValueUpdated, - signalProxy(), - &QRuntimeViewSignalProxy::SigDataOutputValueUpdated); + const auto preslist = m_Application->GetPresentationList(); + + // Connect signalproxies of every presentation. + for (const auto &it : preslist) { + it->signalProxy()->moveToThread((QThread::currentThread())); + QObject::connect(it->signalProxy(), &QPresentationSignalProxy::SigSlideEntered, + signalProxy(), &QRuntimeViewSignalProxy::SigSlideEntered); + QObject::connect(it->signalProxy(), &QPresentationSignalProxy::SigSlideExited, + signalProxy(), &QRuntimeViewSignalProxy::SigSlideExited); + QObject::connect(it->signalProxy(), &QPresentationSignalProxy::SigCustomSignal, + signalProxy(), &QRuntimeViewSignalProxy::SigCustomSignal); + QObject::connect(it->signalProxy(), + &QPresentationSignalProxy::SigPresentationReady, + signalProxy(), &QRuntimeViewSignalProxy::SigPresentationReady); + QObject::connect(it->signalProxy(), &QPresentationSignalProxy::SigElementsCreated, + signalProxy(), &QRuntimeViewSignalProxy::SigElementsCreated); + QObject::connect(it->signalProxy(), &QPresentationSignalProxy::SigMaterialsCreated, + signalProxy(), &QRuntimeViewSignalProxy::SigMaterialsCreated); + QObject::connect(it->signalProxy(), + &QPresentationSignalProxy::SigDataOutputValueUpdated, + signalProxy(), + &QRuntimeViewSignalProxy::SigDataOutputValueUpdated); + } } void CRuntimeView::finishAsyncInit() @@ -358,6 +363,11 @@ void CRuntimeView::Cleanup() { // Q3DStudio_virtual_delete( m_Timer, CTimer ); // Q3DStudio_virtual_delete( m_PerfFileStream, CFileStream ); + const auto preslist = m_Application->GetPresentationList(); + + for (const auto &it : preslist) + QObject::disconnect(it->signalProxy(), 0, signalProxy(), 0); + m_Application = nullptr; Q3DStudio_virtual_delete(m_InputEngine, CTegraInputEngine); if (m_RenderEngine) { @@ -367,8 +377,6 @@ void CRuntimeView::Cleanup() CDLLManager &theDLLManager = CDLLManager::GetDLLManager(); theDLLManager.Cleanup(); - if (m_Presentation) - QObject::disconnect(m_Presentation->signalProxy(), 0, signalProxy(), 0); m_InputEngine = nullptr; m_RenderEngine = nullptr; diff --git a/src/runtime/Qt3DSComponentManager.cpp b/src/runtime/Qt3DSComponentManager.cpp index 8849b5b..1700222 100644 --- a/src/runtime/Qt3DSComponentManager.cpp +++ b/src/runtime/Qt3DSComponentManager.cpp @@ -100,7 +100,13 @@ void CComponentManager::GotoSlideIndex(TElement *inComponent, const UINT8 theCurrentSlideIndex = theComponent->GetCurrentSlide(); - QString elementPath = QString::fromUtf8(inComponent->m_Path.c_str()); + QString elementPath; + // Primary presentation stores elementpaths with subpresentation prefix. + // Prepend it here so that slide change notification is directed at a correct elementpath. + if (&m_Presentation != m_Presentation.GetApplication().GetPrimaryPresentation()) + elementPath = m_Presentation.GetName() + QLatin1Char(':'); + + elementPath.append(QString::fromUtf8(inComponent->m_Path.c_str())); if (inSlideExit) { SEventCommand theEvent = { inComponent, EVENT_ONSLIDEEXIT }; -- cgit v1.2.3