aboutsummaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2021-12-02 15:00:20 +0200
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2021-12-07 09:00:25 +0000
commit9c15b5b16db171890039d4d2ca6d40c5d9358cf4 (patch)
tree3270d4c4d122f78a6ca2e088f97a87b1b54d9c9d /share
parentb6a996a8d5c9246ca41b15aaba7c527df2872513 (diff)
QmlDesigner: Update _pickTarget of Repeater3D created objects
The objects Repeater3D creates are created after handleInstanceHidden is called for the repeater instance, so the _pickTarget of the created children doesn't get properly updated. Added signal handler to make sure handleInstanceHidden is called again after all objects have been created. Fixes: QDS-5643 Change-Id: I8b63614fca0be3956b6896028e3f3a0f49bfe397 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Diffstat (limited to 'share')
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp28
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h4
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dnodeinstance.cpp10
3 files changed, 42 insertions, 0 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp
index 16dc3dbe5f..70dc4b8cc9 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp
@@ -99,6 +99,7 @@
#include <QtQuick3D/private/qquick3dabstractlight_p.h>
#include <QtQuick3D/private/qquick3dviewport_p.h>
#include <QtQuick3D/private/qquick3dscenerootnode_p.h>
+#include <QtQuick3D/private/qquick3drepeater_p.h>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include "../editor3d/qt5compat/qquick3darealight_p.h"
#endif
@@ -1226,6 +1227,7 @@ Qt5InformationNodeInstanceServer::Qt5InformationNodeInstanceServer(NodeInstanceC
m_inputEventTimer.setSingleShot(true);
m_renderModelNodeImageViewTimer.setSingleShot(true);
m_modelNode3DImageViewAsyncData.timer.setSingleShot(true);
+ m_repeaterAddObjectTimer.setSingleShot(true);
#ifdef FPS_COUNTER
if (!_fpsTimer) {
@@ -1251,6 +1253,7 @@ Qt5InformationNodeInstanceServer::~Qt5InformationNodeInstanceServer()
m_inputEventTimer.stop();
m_renderModelNodeImageViewTimer.stop();
m_modelNode3DImageViewAsyncData.timer.stop();
+ m_repeaterAddObjectTimer.stop();
if (m_editView3DData.rootItem)
m_editView3DData.rootItem->disconnect(this);
@@ -1394,6 +1397,22 @@ void Qt5InformationNodeInstanceServer::handleSelectionChangeTimeout()
changeSelection(m_lastSelectionChangeCommand);
}
+void Qt5InformationNodeInstanceServer::handleRepeaterAddObjectTimeout()
+{
+#ifdef QUICK3D_MODULE
+ for (auto obj : std::as_const(m_addObjectRepeaters)) {
+ if (auto repObj = qobject_cast<QQuick3DRepeater *>(obj)) {
+ if (hasInstanceForObject(repObj)) {
+ ServerNodeInstance instance = instanceForObject(repObj);
+ handleInstanceHidden(instance, instance.internalInstance()->isHiddenInEditor(),
+ false);
+ }
+ }
+ }
+#endif
+ m_addObjectRepeaters.clear();
+}
+
void Qt5InformationNodeInstanceServer::createCameraAndLightGizmos(
const QList<ServerNodeInstance> &instanceList) const
{
@@ -1645,6 +1664,8 @@ void Qt5InformationNodeInstanceServer::setup3DEditView(const QList<ServerNodeIns
this, &Qt5InformationNodeInstanceServer::handleInputEvents);
QObject::connect(&m_modelNode3DImageViewAsyncData.timer, &QTimer::timeout,
this, &Qt5InformationNodeInstanceServer::modelNode3DImageViewRenderStep);
+ QObject::connect(&m_repeaterAddObjectTimer, &QTimer::timeout,
+ this, &Qt5InformationNodeInstanceServer::handleRepeaterAddObjectTimeout);
QString lastSceneId;
auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper);
@@ -1803,6 +1824,7 @@ void Qt5InformationNodeInstanceServer::clearScene(const ClearSceneCommand &comma
m_parentChangedSet.clear();
m_completedComponentList.clear();
+ m_addObjectRepeaters.clear();
}
void Qt5InformationNodeInstanceServer::createScene(const CreateSceneCommand &command)
@@ -2293,6 +2315,12 @@ bool Qt5InformationNodeInstanceServer::isInformationServer() const
return true;
}
+void Qt5InformationNodeInstanceServer::handleRepeaterAddObject()
+{
+ m_addObjectRepeaters.insert(sender());
+ m_repeaterAddObjectTimer.start();
+}
+
// update 3D view size when it changes in creator side
void Qt5InformationNodeInstanceServer::update3DViewState(const Update3dViewStateCommand &command)
{
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h
index 3d96b3bb70..439b7b17a3 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h
@@ -82,6 +82,7 @@ public:
void handleInstanceHidden(const ServerNodeInstance &instance, bool enable, bool checkAncestors) override;
bool isInformationServer() const override;
+ void handleRepeaterAddObject();
private slots:
void handleSelectionChanged(const QVariant &objs);
@@ -108,6 +109,7 @@ protected:
private:
void handleObjectPropertyChangeTimeout();
void handleSelectionChangeTimeout();
+ void handleRepeaterAddObjectTimeout();
void createEditView3D();
void create3DPreviewView();
void setup3DEditView(const QList<ServerNodeInstance> &instanceList,
@@ -174,6 +176,7 @@ private:
QTimer m_render3DEditViewTimer;
QTimer m_renderModelNodeImageViewTimer;
QTimer m_inputEventTimer;
+ QTimer m_repeaterAddObjectTimer;
#ifdef QUICK3D_PARTICLES_MODULE
bool m_particleAnimationPlaying = true;
AnimationDriver *m_particleAnimationDriver = nullptr;
@@ -186,6 +189,7 @@ private:
QList<InputEventCommand> m_pendingInputEventCommands;
QObject *m_3dHelper = nullptr;
int m_need3DEditViewRender = 0;
+ QSet<QObject *> m_addObjectRepeaters;
struct ModelNode3DImageViewAsyncData {
QTimer timer;
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dnodeinstance.cpp
index c8bbc46ddb..783bfba87f 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dnodeinstance.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dnodeinstance.cpp
@@ -25,6 +25,7 @@
#include "quick3dnodeinstance.h"
#include "qt5nodeinstanceserver.h"
+#include "qt5informationnodeinstanceserver.h"
#include <qmlprivategate.h>
@@ -39,6 +40,7 @@
#include <private/qquick3dnode_p.h>
#include <private/qquick3dmodel_p.h>
#include <private/qquick3dnode_p_p.h>
+#include <private/qquick3drepeater_p.h>
#endif
namespace QmlDesigner {
@@ -56,6 +58,14 @@ Quick3DNodeInstance::~Quick3DNodeInstance()
void Quick3DNodeInstance::initialize(const ObjectNodeInstance::Pointer &objectNodeInstance,
InstanceContainer::NodeFlags flags)
{
+#ifdef QUICK3D_MODULE
+ if (auto repObj = qobject_cast<QQuick3DRepeater *>(object())) {
+ if (auto infoServer = qobject_cast<Qt5InformationNodeInstanceServer *>(nodeInstanceServer())) {
+ QObject::connect(repObj, &QQuick3DRepeater::objectAdded,
+ infoServer, &Qt5InformationNodeInstanceServer::handleRepeaterAddObject);
+ }
+ }
+#endif
ObjectNodeInstance::initialize(objectNodeInstance, flags);
}