From 74a1bf8d89eb3a62e0803264cea14568e83dc690 Mon Sep 17 00:00:00 2001 From: Jere Tuliniemi Date: Wed, 6 May 2020 09:59:31 +0300 Subject: Fix data inputs with delayed loading MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Initialize data inputs and outputs every time a presentation is loaded. Task-number: QT3DS-4105 Change-Id: If2e9a6d95cc40109cb48f4d4d8b5dc88f963fb74 Reviewed-by: Tomi Korpipää Reviewed-by: Antti Määttä --- src/runtime/Qt3DSApplication.cpp | 4 ++++ src/runtime/Qt3DSIScriptBridge.h | 1 + src/runtime/Qt3DSQmlEngine.cpp | 13 +++++++++++++ 3 files changed, 18 insertions(+) diff --git a/src/runtime/Qt3DSApplication.cpp b/src/runtime/Qt3DSApplication.cpp index f12fef9..7b4d625 100644 --- a/src/runtime/Qt3DSApplication.cpp +++ b/src/runtime/Qt3DSApplication.cpp @@ -2277,6 +2277,10 @@ bool AssetHandlers::handlePresentation(SApp &app, SAssetValue &asset, bool initI thePathStr.c_str()); return false; } + + app.GetRuntimeFactory().GetScriptEngineQml() + .initializePresentationDataInputsAndOutputs(*thePresentationAsset.m_Presentation); + return true; } diff --git a/src/runtime/Qt3DSIScriptBridge.h b/src/runtime/Qt3DSIScriptBridge.h index 9eedfc5..cb13fb2 100644 --- a/src/runtime/Qt3DSIScriptBridge.h +++ b/src/runtime/Qt3DSIScriptBridge.h @@ -202,6 +202,7 @@ public: // Components public: // Presentation virtual void SetPresentationAttribute(const char *presId, const char *attName, const char *attValue) = 0; + virtual void initializePresentationDataInputsAndOutputs(CPresentation &presentation) = 0; public: // Multimedia virtual bool PlaySoundFile(const char *soundPath) = 0; diff --git a/src/runtime/Qt3DSQmlEngine.cpp b/src/runtime/Qt3DSQmlEngine.cpp index d063e5e..994f6c1 100644 --- a/src/runtime/Qt3DSQmlEngine.cpp +++ b/src/runtime/Qt3DSQmlEngine.cpp @@ -460,6 +460,7 @@ public: void GotoSlideRelative(const char *, bool, bool, const SScriptEngineGotoSlideArgs &) override; void SetPresentationAttribute(const char *, const char *, const char *) override; + void initializePresentationDataInputsAndOutputs(CPresentation &presentation); // No need to implement here, as sound playing is done in Qt3DSViewerApp bool PlaySoundFile(const char *) override { return false; } @@ -1917,6 +1918,12 @@ void CQmlEngineImpl::SetPresentationAttribute(const char *presId, const char *, } } +void CQmlEngineImpl::initializePresentationDataInputsAndOutputs(CPresentation &presentation) +{ + initializeDataInputsInPresentation(presentation, false); + initializeDataOutputsInPresentation(presentation, false); +} + void CQmlEngineImpl::GotoSlideIndex(const char *component, const Q3DStudio::INT32 slideIndex, const SScriptEngineGotoSlideArgs &inArgs) { @@ -2135,6 +2142,9 @@ void CQmlEngineImpl::initializeDataInputsInPresentation(CPresentation &presentat bool isPrimary, bool isDynamicAdd, QList inElements) { + if (!m_Application) + return; + QList elements; if (!inElements.empty()) { elements = inElements; @@ -2310,6 +2320,9 @@ void CQmlEngineImpl::initializeDataInputsInPresentation(CPresentation &presentat void CQmlEngineImpl::initializeDataOutputsInPresentation(CPresentation &presentation, bool isPrimary) { + if (!m_Application) + return; + TElement *parent = presentation.GetRoot(); QList elements; listAllElements(parent, elements); -- cgit v1.2.3