QmlDesigner: Show id-less scenes properly in 3D edit view

Fixes: QDS-6942
Change-Id: I5b7fa966bf9d7321b1735ef0ea7cb904b82f542d
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Miikka Heikkinen
2022-05-18 15:16:15 +03:00
parent e608243ee5
commit 6dda55a8cd
2 changed files with 18 additions and 8 deletions

View File

@@ -800,7 +800,7 @@ void Qt5InformationNodeInstanceServer::updateView3DRect(QObject *view3D)
viewPortProperty.write(viewPortrect);
}
void Qt5InformationNodeInstanceServer::updateActiveSceneToEditView3D()
void Qt5InformationNodeInstanceServer::updateActiveSceneToEditView3D(bool timerCall)
{
#ifdef QUICK3D_MODULE
if (!m_editView3DSetupDone)
@@ -816,12 +816,16 @@ void Qt5InformationNodeInstanceServer::updateActiveSceneToEditView3D()
ServerNodeInstance sceneInstance = active3DSceneInstance();
const QString sceneId = sceneInstance.id();
// QML item id is updated with separate call, so delay this update until we have it
if (m_active3DScene && sceneId.isEmpty()) {
m_active3DSceneUpdatePending = true;
// In case of newly created scene node, QML item id is updated with separate command immediately
// after the creation of the node, so delay this update for a moment in case we get it.
// The changeId command should already be waiting to be handled, so we can use very short
// interval timer. If we haven't gotten the scene id by the time the timer triggers, we can
// assume scene node doesn't have an id.
if (m_active3DScene && !timerCall && sceneId.isEmpty()) {
m_activeSceneIdUpdateTimer.start();
return;
} else {
m_active3DSceneUpdatePending = false;
m_activeSceneIdUpdateTimer.stop();
}
QMetaObject::invokeMethod(m_editView3DData.rootItem, "setActiveScene", Qt::QueuedConnection,
@@ -1266,6 +1270,8 @@ Qt5InformationNodeInstanceServer::Qt5InformationNodeInstanceServer(NodeInstanceC
m_inputEventTimer.setSingleShot(true);
m_renderModelNodeImageViewTimer.setSingleShot(true);
m_dynamicAddObjectTimer.setSingleShot(true);
m_activeSceneIdUpdateTimer.setInterval(20);
m_activeSceneIdUpdateTimer.setSingleShot(true);
#ifdef FPS_COUNTER
if (!_fpsTimer) {
@@ -1291,6 +1297,7 @@ Qt5InformationNodeInstanceServer::~Qt5InformationNodeInstanceServer()
m_inputEventTimer.stop();
m_renderModelNodeImageViewTimer.stop();
m_dynamicAddObjectTimer.stop();
m_activeSceneIdUpdateTimer.stop();
if (m_editView3DData.rootItem)
m_editView3DData.rootItem->disconnect(this);
@@ -1724,6 +1731,9 @@ void Qt5InformationNodeInstanceServer::setup3DEditView(const QList<ServerNodeIns
this, &Qt5InformationNodeInstanceServer::handleInputEvents);
QObject::connect(&m_dynamicAddObjectTimer, &QTimer::timeout,
this, &Qt5InformationNodeInstanceServer::handleDynamicAddObjectTimeout);
QObject::connect(&m_activeSceneIdUpdateTimer, &QTimer::timeout, this, [this]() {
Qt5InformationNodeInstanceServer::updateActiveSceneToEditView3D(true);
});
QString lastSceneId;
auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper);
@@ -2243,7 +2253,7 @@ void Qt5InformationNodeInstanceServer::changeIds(const ChangeIdsCommand &command
#ifdef QUICK3D_MODULE
if (m_editView3DSetupDone) {
ServerNodeInstance sceneInstance = active3DSceneInstance();
if (m_active3DSceneUpdatePending) {
if (m_activeSceneIdUpdateTimer.isActive()) {
const QString sceneId = sceneInstance.id();
if (!sceneId.isEmpty())
updateActiveSceneToEditView3D();

View File

@@ -129,7 +129,7 @@ private:
const QList<PropertyName> &propNames,
ValuesModifiedCommand::TransactionOption option);
void updateView3DRect(QObject *view3D);
void updateActiveSceneToEditView3D();
void updateActiveSceneToEditView3D(bool timerCall = false);
void removeNode3D(QObject *node);
void resolveSceneRoots();
ServerNodeInstance active3DSceneInstance() const;
@@ -165,7 +165,6 @@ private:
QMultiHash<QObject *, QObject *> m_3DSceneMap; // key: scene root, value: node
QObject *m_active3DView = nullptr;
QObject *m_active3DScene = nullptr;
bool m_active3DSceneUpdatePending = false;
QSet<ServerNodeInstance> m_parentChangedSet;
QList<ServerNodeInstance> m_completedComponentList;
QList<TokenCommand> m_tokenList;
@@ -175,6 +174,7 @@ private:
QTimer m_renderModelNodeImageViewTimer;
QTimer m_inputEventTimer;
QTimer m_dynamicAddObjectTimer;
QTimer m_activeSceneIdUpdateTimer;
#ifdef QUICK3D_PARTICLES_MODULE
bool m_particleAnimationPlaying = true;
AnimationDriver *m_particleAnimationDriver = nullptr;