forked from qt-creator/qt-creator
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:
@@ -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();
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
const QPointF &position,
|
||||
NodeAbstractProperty parentproperty,
|
||||
bool executeInTransaction = true);
|
||||
static QmlItemNode createQmlItemNodeForEffect(AbstractView *view,
|
||||
static void createQmlItemNodeForEffect(AbstractView *view,
|
||||
const QmlItemNode &parentNode,
|
||||
const QString &effectName);
|
||||
QList<QmlItemNode> children() const;
|
||||
|
||||
@@ -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,7 +162,7 @@ static bool useLayerEffect()
|
||||
return settings->value(layerEffectEntry, true).toBool();
|
||||
}
|
||||
|
||||
QmlItemNode QmlItemNode::createQmlItemNodeForEffect(AbstractView *view,
|
||||
void QmlItemNode::createQmlItemNodeForEffect(AbstractView *view,
|
||||
const QmlItemNode &parentNode,
|
||||
const QString &effectName)
|
||||
{
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user