QmlDesigner: crash when dragging an effect twice to component in 2D

When an effect is dragged twice, same effect or other effect it caused
QDS to crash, in layer mode the effect is replaced,
otherwise effect is added upon previous effect

Task-number: QDS-8172
Change-Id: I2a3682b21492de0d0cc62bce9bd2965cedfbc826
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Amr Essam
2022-11-11 10:07:53 +02:00
committed by amr.elsayed
parent 8bb3c8f923
commit e3e5524f88
3 changed files with 11 additions and 15 deletions

View File

@@ -230,8 +230,8 @@ void DragTool::dropEvent(const QList<QGraphicsItem *> &itemList, QGraphicsSceneD
QString effectPath;
const QStringList assetPaths = QString::fromUtf8(event->mimeData()
->data(Constants::MIME_TYPE_ASSETS)).split(',');
for (auto &path : assetPaths) {
auto assetType = AssetsLibraryWidget::getAssetTypeAndData(path).first;
for (const QString &path : assetPaths) {
const QString assetType = AssetsLibraryWidget::getAssetTypeAndData(path).first;
if (assetType == Constants::MIME_TYPE_ASSET_EFFECT) {
effectPath = path;
break;
@@ -266,8 +266,7 @@ void DragTool::dropEvent(const QList<QGraphicsItem *> &itemList, QGraphicsSceneD
return;
}
QmlItemNode effectNode = QmlItemNode::
createQmlItemNodeForEffect(view(), parentQmlItemNode, effectName);
QmlItemNode::createQmlItemNodeForEffect(view(), parentQmlItemNode, effectName);
view()->setSelectedModelNodes({parentQmlItemNode});
view()->resetPuppet();

View File

@@ -60,9 +60,9 @@ public:
const QPointF &position,
NodeAbstractProperty parentproperty,
bool executeInTransaction = true);
static QmlItemNode createQmlItemNodeForEffect(AbstractView *view,
const QmlItemNode &parentNode,
const QString &effectName);
static void createQmlItemNodeForEffect(AbstractView *view,
const QmlItemNode &parentNode,
const QString &effectName);
QList<QmlItemNode> children() const;
QList<QmlObjectNode> resources() const;
QList<QmlObjectNode> allDirectSubNodes() const;

View File

@@ -5,6 +5,7 @@
#include <metainfo.h>
#include "nodelistproperty.h"
#include "nodehints.h"
#include "nodeproperty.h"
#include "variantproperty.h"
#include "bindingproperty.h"
#include "qmlanchors.h"
@@ -161,9 +162,9 @@ static bool useLayerEffect()
return settings->value(layerEffectEntry, true).toBool();
}
QmlItemNode QmlItemNode::createQmlItemNodeForEffect(AbstractView *view,
const QmlItemNode &parentNode,
const QString &effectName)
void QmlItemNode::createQmlItemNodeForEffect(AbstractView *view,
const QmlItemNode &parentNode,
const QString &effectName)
{
QmlItemNode newQmlItemNode;
@@ -174,7 +175,7 @@ QmlItemNode QmlItemNode::createQmlItemNodeForEffect(AbstractView *view,
if (!view->model()->hasImport(import, true, true))
view->model()->changeImports({import}, {});
} catch (const Exception &) {
QTC_ASSERT(false, return QmlItemNode());
QTC_ASSERT(false, return);
}
TypeName type(effectName.toUtf8());
@@ -190,10 +191,6 @@ QmlItemNode QmlItemNode::createQmlItemNodeForEffect(AbstractView *view,
} else {
parentNode.modelNode().variantProperty("layer.enabled").setValue(true);
}
QTC_ASSERT(newQmlItemNode.isValid(), return QmlItemNode());
return newQmlItemNode;
}
bool QmlItemNode::isValid() const