Commit f97df3e9 authored by Marco Bubke's avatar Marco Bubke

QmlDesigner: Add RewriterTransaction tracing framework

Change-Id: I6c152e128e0a1b1d4450bbba81e47d072aac3038
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 721feaf5
......@@ -32,6 +32,7 @@
#include <cmath>
#include <QMessageBox>
#include <QByteArray>
#include <nodeabstractproperty.h>
#include <nodemetainfo.h>
#include <modelnode.h>
......@@ -211,7 +212,7 @@ void raise(const SelectionContext &selectionState)
return;
try {
RewriterTransaction transaction(selectionState.view());
RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|raise"));
foreach (ModelNode modelNode, selectionState.selectedModelNodes()) {
QmlItemNode node = modelNode;
if (node.isValid()) {
......@@ -232,7 +233,7 @@ void lower(const SelectionContext &selectionState)
return;
try {
RewriterTransaction transaction(selectionState.view());
RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|lower"));
foreach (ModelNode modelNode, selectionState.selectedModelNodes()) {
QmlItemNode node = modelNode;
if (node.isValid()) {
......@@ -302,7 +303,7 @@ void resetSize(const SelectionContext &selectionState)
return;
try {
RewriterTransaction transaction(selectionState.view());
RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|resetSize"));
foreach (ModelNode node, selectionState.selectedModelNodes()) {
node.removeProperty("width");
node.removeProperty("height");
......@@ -318,7 +319,7 @@ void resetPosition(const SelectionContext &selectionState)
return;
try {
RewriterTransaction transaction(selectionState.view());
RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|resetPosition"));
foreach (ModelNode node, selectionState.selectedModelNodes()) {
node.removeProperty("x");
node.removeProperty("y");
......@@ -342,7 +343,7 @@ void resetZ(const SelectionContext &selectionState)
if (!selectionState.view())
return;
RewriterTransaction transaction(selectionState.view());
RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|resetZ"));
foreach (ModelNode node, selectionState.selectedModelNodes()) {
node.removeProperty("z");
}
......@@ -373,7 +374,7 @@ void anchorsFill(const SelectionContext &selectionState)
if (!selectionState.view())
return;
RewriterTransaction transaction(selectionState.view());
RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|anchorsFill"));
ModelNode modelNode = selectionState.currentSingleSelectedNode();
......@@ -392,7 +393,7 @@ void anchorsReset(const SelectionContext &selectionState)
if (!selectionState.view())
return;
RewriterTransaction transaction(selectionState.view());
RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|anchorsReset"));
ModelNode modelNode = selectionState.currentSingleSelectedNode();
......@@ -458,7 +459,7 @@ static void layoutHelperFunction(const SelectionContext &selectionContext,
ModelNode layoutNode;
{
RewriterTransaction transaction(selectionContext.view());
RewriterTransaction transaction(selectionContext.view(), QByteArrayLiteral("DesignerActionManager|layoutHelperFunction1"));
QmlItemNode parentNode = qmlItemNode.instanceParentItem();
......@@ -470,7 +471,7 @@ static void layoutHelperFunction(const SelectionContext &selectionContext,
}
{
RewriterTransaction transaction(selectionContext.view());
RewriterTransaction transaction(selectionContext.view(), QByteArrayLiteral("DesignerActionManager|layoutHelperFunction2"));
QList<ModelNode> sortedSelectedNodes = selectionContext.selectedModelNodes();
qSort(sortedSelectedNodes.begin(), sortedSelectedNodes.end(), lessThan);
......
......@@ -321,7 +321,7 @@ void DragTool::dragEnterEvent(QGraphicsSceneDragDropEvent * event)
if (!m_rewriterTransaction.isValid()) {
view()->clearSelectedModelNodes();
m_rewriterTransaction = view()->beginRewriterTransaction();
m_rewriterTransaction = view()->beginRewriterTransaction(QByteArrayLiteral("DragTool::dragEnterEvent"));
}
}
}
......
......@@ -159,7 +159,7 @@ void MoveManipulator::begin(const QPointF &beginPoint)
// setOpacityForAllElements(0.62);
m_rewriterTransaction = m_view->beginRewriterTransaction();
m_rewriterTransaction = m_view->beginRewriterTransaction(QByteArrayLiteral("MoveManipulator::begin"));
}
......@@ -421,7 +421,7 @@ void MoveManipulator::moveBy(double deltaX, double deltaY)
void MoveManipulator::beginRewriterTransaction()
{
m_rewriterTransaction = m_view->beginRewriterTransaction();
m_rewriterTransaction = m_view->beginRewriterTransaction(QByteArrayLiteral("MoveManipulator::beginRewriterTransaction"));
}
void MoveManipulator::endRewriterTransaction()
......
......@@ -81,7 +81,7 @@ void ResizeManipulator::begin(const QPointF &/*beginPoint*/)
m_beginFromSceneToContentItemTransform = m_beginFromContentItemToSceneTransform.inverted();
m_beginFromItemToSceneTransform = m_resizeController.formEditorItem()->qmlItemNode().instanceSceneTransform();
m_beginToParentTransform = m_resizeController.formEditorItem()->qmlItemNode().instanceTransform();
m_rewriterTransaction = m_view->beginRewriterTransaction();
m_rewriterTransaction = m_view->beginRewriterTransaction(QByteArrayLiteral("ResizeManipulator::begin"));
m_snapper.updateSnappingLines(m_resizeController.formEditorItem());
m_beginBottomRightPoint = m_beginToParentTransform.map(m_resizeController.formEditorItem()->qmlItemNode().instanceBoundingRect().bottomRight());
......
......@@ -356,7 +356,7 @@ void DesignDocument::deleteSelected()
return;
try {
RewriterTransaction transaction(rewriterView());
RewriterTransaction transaction(rewriterView(), QByteArrayLiteral("DesignDocument::deleteSelected"));
QList<ModelNode> toDelete = view()->selectedModelNodes();
foreach (ModelNode node, toDelete) {
if (node.isValid() && !node.isRootNode() && QmlObjectNode::isValidQmlObjectNode(node))
......@@ -511,7 +511,7 @@ void DesignDocument::paste()
QList<ModelNode> pastedNodeList;
try {
RewriterTransaction transaction(rewriterView());
RewriterTransaction transaction(rewriterView(), QByteArrayLiteral("DesignDocument::paste1"));
int offset = double(qrand()) / RAND_MAX * 20 - 10;
......@@ -529,7 +529,7 @@ void DesignDocument::paste()
}
} else {
try {
RewriterTransaction transaction(rewriterView());
RewriterTransaction transaction(rewriterView(), QByteArrayLiteral("DesignDocument::paste2"));
pasteModel->detachView(&view);
currentModel()->attachView(&view);
......
......@@ -510,7 +510,7 @@ void NavigatorTreeModel::moveNodesInteractive(NodeAbstractProperty parentPropert
try {
TypeName propertyQmlType = qmlTypeInQtContainer(parentProperty.parentModelNode().metaInfo().propertyTypeName(parentProperty.name()));
RewriterTransaction transaction = m_view->beginRewriterTransaction();
RewriterTransaction transaction = m_view->beginRewriterTransaction(QByteArrayLiteral("NavigatorTreeModel::moveNodesInteractive"));
foreach (const ModelNode &node, modelNodes) {
if (!node.isValid())
continue;
......
......@@ -131,7 +131,7 @@ void GradientLineQmlAdaptor::writeGradient()
ModelNode gradientNode= modelNode.view()->createModelNode("QtQuick.Gradient", modelNode.view()->majorQtQuickVersion(), 0);
modelNode.nodeProperty(gradientName().toUtf8()).reparentHere(gradientNode);
RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("GradientLineQmlAdaptor::writeGradient"));
if (!oldId.isNull())
gradientNode.setId(oldId);
......@@ -173,7 +173,7 @@ void GradientLineQmlAdaptor::deleteGradient()
if (m_itemNode.isInBaseState()) {
if (modelNode.hasProperty(gradientName().toUtf8())) {
RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("GradientLineQmlAdaptor::deleteGradient"));
ModelNode gradientNode = modelNode.nodeProperty(gradientName().toUtf8()).modelNode();
if (QmlObjectNode(gradientNode).isValid())
QmlObjectNode(gradientNode).destroy();
......
......@@ -143,7 +143,7 @@ void GradientModel::addGradient()
if (!color.isValid())
color = QColor(Qt::white);
QmlDesigner::RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction();
QmlDesigner::RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("GradientModel::addGradient"));
QmlDesigner::ModelNode gradientNode =
m_itemNode.modelNode().view()->createModelNode("QtQuick.Gradient",
......@@ -227,7 +227,7 @@ qreal GradientModel::getPosition(int index) const
void GradientModel::removeStop(int index)
{
if (index < rowCount() - 1 && index != 0) {
QmlDesigner::RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction();
QmlDesigner::RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("GradientModel::removeStop"));
QmlDesigner::ModelNode gradientNode = m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).modelNode();
QmlDesigner::QmlObjectNode stop = gradientNode.nodeListProperty("stops").toModelNodeList().at(index);
if (stop.isValid()) {
......@@ -251,7 +251,7 @@ void GradientModel::deleteGradient()
if (m_itemNode.isInBaseState()) {
if (modelNode.hasProperty(gradientPropertyName().toUtf8())) {
QmlDesigner::RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction();
QmlDesigner::RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("GradientModel::deleteGradient"));
QmlDesigner::ModelNode gradientNode = modelNode.nodeProperty(gradientPropertyName().toUtf8()).modelNode();
if (QmlDesigner::QmlObjectNode(gradientNode).isValid())
QmlDesigner::QmlObjectNode(gradientNode).destroy();
......
......@@ -44,7 +44,7 @@ void PropertyEditorTransaction::start()
return;
if (m_rewriterTransaction.isValid())
m_rewriterTransaction.commit();
m_rewriterTransaction = m_propertyEditor->beginRewriterTransaction();
m_rewriterTransaction = m_propertyEditor->beginRewriterTransaction(QByteArrayLiteral("PropertyEditorTransaction::start"));
m_timerId = startTimer(4000);
}
......
......@@ -240,7 +240,7 @@ void PropertyEditorView::changeExpression(const QString &propertyName)
if (m_locked)
return;
RewriterTransaction transaction = beginRewriterTransaction();
RewriterTransaction transaction = beginRewriterTransaction(QByteArrayLiteral("PropertyEditorView::changeExpression"));
try {
PropertyName underscoreName(name);
......
......@@ -268,7 +268,7 @@ void QmlAnchorBindingProxy::setTopTarget(const QString &target)
if (!newTarget.isValid())
return;
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setTopTarget"));
m_topTarget = newTarget;
calcTopMargin();
......@@ -293,7 +293,7 @@ void QmlAnchorBindingProxy::setBottomTarget(const QString &target)
if (!newTarget.isValid())
return;
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setBottomTarget"));
m_bottomTarget = newTarget;
calcBottomMargin();
......@@ -314,7 +314,7 @@ void QmlAnchorBindingProxy::setLeftTarget(const QString &target)
if (!newTarget.isValid())
return;
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setLeftTarget"));
m_leftTarget = newTarget;
calcLeftMargin();
......@@ -335,7 +335,7 @@ void QmlAnchorBindingProxy::setRightTarget(const QString &target)
if (!newTarget.isValid())
return;
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setRightTarget"));
m_rightTarget = newTarget;
calcRightMargin();
......@@ -356,7 +356,7 @@ void QmlAnchorBindingProxy::setVerticalTarget(const QString &target)
if (!newTarget.isValid())
return;
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setVerticalTarget"));
m_verticalTarget = newTarget;
m_qmlItemNode.anchors().setAnchor(AnchorLine::VerticalCenter, m_verticalTarget, AnchorLine::VerticalCenter);
......@@ -377,7 +377,7 @@ void QmlAnchorBindingProxy::setHorizontalTarget(const QString &target)
if (!newTarget.isValid())
return;
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setHorizontalTarget"));
m_horizontalTarget = newTarget;
m_qmlItemNode.anchors().setAnchor(AnchorLine::HorizontalCenter, m_horizontalTarget, AnchorLine::HorizontalCenter);
......@@ -421,7 +421,7 @@ int QmlAnchorBindingProxy::indexOfPossibleTargetItem(const QString &targetName)
}
void QmlAnchorBindingProxy::resetLayout() {
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::resetLayout"));
m_qmlItemNode.anchors().removeAnchors();
m_qmlItemNode.anchors().removeMargins();
......@@ -446,7 +446,7 @@ void QmlAnchorBindingProxy::setBottomAnchor(bool anchor)
if (bottomAnchored() == anchor)
return;
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setBottomAnchor"));
if (!anchor) {
removeBottomAnchor();
......@@ -469,7 +469,7 @@ void QmlAnchorBindingProxy::setLeftAnchor(bool anchor)
if (leftAnchored() == anchor)
return;
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setLeftAnchor"));
if (!anchor) {
removeLeftAnchor();
......@@ -493,7 +493,7 @@ void QmlAnchorBindingProxy::setRightAnchor(bool anchor)
if (rightAnchored() == anchor)
return;
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setRightAnchor"));
if (!anchor) {
removeRightAnchor();
......@@ -634,7 +634,7 @@ void QmlAnchorBindingProxy::setTopAnchor(bool anchor)
if (topAnchored() == anchor)
return;
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setTopAnchor"));
if (!anchor) {
removeTopAnchor();
......@@ -650,7 +650,7 @@ void QmlAnchorBindingProxy::setTopAnchor(bool anchor)
}
void QmlAnchorBindingProxy::removeTopAnchor() {
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::removeTopAnchor"));
m_qmlItemNode.anchors().removeAnchor(AnchorLine::Top);
m_qmlItemNode.anchors().removeMargin(AnchorLine::Top);
......@@ -661,7 +661,7 @@ void QmlAnchorBindingProxy::removeTopAnchor() {
}
void QmlAnchorBindingProxy::removeBottomAnchor() {
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::removeBottomAnchor"));
m_qmlItemNode.anchors().removeAnchor(AnchorLine::Bottom);
m_qmlItemNode.anchors().removeMargin(AnchorLine::Bottom);
......@@ -671,7 +671,7 @@ void QmlAnchorBindingProxy::removeBottomAnchor() {
}
void QmlAnchorBindingProxy::removeLeftAnchor() {
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::removeLeftAnchor"));
m_qmlItemNode.anchors().removeAnchor(AnchorLine::Left);
m_qmlItemNode.anchors().removeMargin(AnchorLine::Left);
......@@ -681,7 +681,7 @@ void QmlAnchorBindingProxy::removeLeftAnchor() {
}
void QmlAnchorBindingProxy::removeRightAnchor() {
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::removeRightAnchor"));
m_qmlItemNode.anchors().removeAnchor(AnchorLine::Right);
m_qmlItemNode.anchors().removeMargin(AnchorLine::Right);
......@@ -699,7 +699,7 @@ void QmlAnchorBindingProxy::setVerticalCentered(bool centered)
m_locked = true;
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setVerticalCentered"));
if (!centered) {
m_qmlItemNode.anchors().removeAnchor(AnchorLine::VerticalCenter);
......@@ -723,7 +723,7 @@ void QmlAnchorBindingProxy::setHorizontalCentered(bool centered)
m_locked = true;
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setHorizontalCentered"));
if (!centered) {
m_qmlItemNode.anchors().removeAnchor(AnchorLine::HorizontalCenter);
......@@ -780,7 +780,7 @@ bool QmlAnchorBindingProxy::horizontalCentered()
void QmlAnchorBindingProxy::fill()
{
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::fill"));
backupPropertyAndRemove(modelNode(), "x");
......
......@@ -132,7 +132,7 @@ public:
Model* model() const;
bool isAttached() const;
RewriterTransaction beginRewriterTransaction();
RewriterTransaction beginRewriterTransaction(const QByteArray &identifier);
ModelNode createModelNode(const TypeName &typeName,
int majorVersion,
......
......@@ -71,9 +71,9 @@ void AbstractView::setModel(Model *model)
m_model = model;
}
RewriterTransaction AbstractView::beginRewriterTransaction()
RewriterTransaction AbstractView::beginRewriterTransaction(const QByteArray &identifier)
{
return RewriterTransaction(this);
return RewriterTransaction(this, identifier);
}
ModelNode AbstractView::createModelNode(const TypeName &typeName,
......
......@@ -154,7 +154,7 @@ static ModelNode createNodeFromNode(const ModelNode &modelNode,const QHash<QStri
ModelNode ModelMerger::insertModel(const ModelNode &modelNode)
{
RewriterTransaction transaction(view()->beginRewriterTransaction());
RewriterTransaction transaction(view()->beginRewriterTransaction(QByteArrayLiteral("ModelMerger::insertModel")));
QList<Import> newImports;
......@@ -179,7 +179,7 @@ void ModelMerger::replaceModel(const ModelNode &modelNode)
view()->model()->setFileUrl(modelNode.model()->fileUrl());
try {
RewriterTransaction transaction(view()->beginRewriterTransaction());
RewriterTransaction transaction(view()->beginRewriterTransaction(QByteArrayLiteral("ModelMerger::replaceModel")));
ModelNode rootNode(view()->rootModelNode());
......
......@@ -176,7 +176,7 @@ void QmlAnchors::setAnchor(AnchorLine::Type sourceAnchorLine,
const QmlItemNode &targetQmlItemNode,
AnchorLine::Type targetAnchorLine)
{
RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchors::setAnchor"));
if (qmlItemNode().isInBaseState()) {
if ((qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLine::Fill))
|| ((qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn") && (sourceAnchorLine & AnchorLine::Center)))) {
......@@ -330,7 +330,7 @@ AnchorLine QmlAnchors::instanceAnchor(AnchorLine::Type sourceAnchorLine) const
void QmlAnchors::removeAnchor(AnchorLine::Type sourceAnchorLine)
{
RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchors::removeAnchor"));
if (qmlItemNode().isInBaseState()) {
const PropertyName propertyName = anchorPropertyName(sourceAnchorLine);
if (qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLine::Fill)) {
......@@ -352,7 +352,7 @@ void QmlAnchors::removeAnchor(AnchorLine::Type sourceAnchorLine)
void QmlAnchors::removeAnchors()
{
RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchors::removeAnchors"));
if (qmlItemNode().nodeInstance().hasAnchor("anchors.fill"))
qmlItemNode().modelNode().removeProperty("anchors.fill");
if (qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn"))
......@@ -540,7 +540,7 @@ void QmlAnchors::removeMargin(AnchorLine::Type sourceAnchorLineType)
void QmlAnchors::removeMargins()
{
RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction();
RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchors::removeMargins"));
removeMargin(AnchorLine::Left);
removeMargin(AnchorLine::Right);
removeMargin(AnchorLine::Top);
......
......@@ -72,7 +72,7 @@ bool QmlModelStateOperation::isValidQmlModelStateOperation(const ModelNode &mode
void QmlPropertyChanges::removeProperty(const PropertyName &name)
{
RewriterTransaction transaction(view()->beginRewriterTransaction());
RewriterTransaction transaction(view()->beginRewriterTransaction(QByteArrayLiteral("QmlPropertyChanges::removeProperty")));
if (name == "name")
return;
modelNode().removeProperty(name);
......
......@@ -100,7 +100,7 @@ QmlItemNode QmlItemNode::createQmlItemNode(AbstractView *view, const ItemLibrary
QmlItemNode newQmlItemNode;
try {
RewriterTransaction transaction = view->beginRewriterTransaction();
RewriterTransaction transaction = view->beginRewriterTransaction(QByteArrayLiteral("QmlItemNode::createQmlItemNode"));
NodeMetaInfo metaInfo = view->model()->metaInfo(itemLibraryEntry.typeName());
......@@ -208,7 +208,7 @@ QmlItemNode QmlItemNode::createQmlItemNodeFromImage(AbstractView *view, const QS
parentQmlItemNode = QmlItemNode(view->rootModelNode());
if (parentQmlItemNode.isValid()) {
RewriterTransaction transaction = view->beginRewriterTransaction();
RewriterTransaction transaction = view->beginRewriterTransaction(QByteArrayLiteral("QmlItemNode::createQmlItemNodeFromImage"));
checkImageImport(view);
......
......@@ -203,7 +203,7 @@ void RewriterView::propertiesAboutToBeRemoved(const QList<AbstractProperty> &pro
foreach (const AbstractProperty &property, propertyList) {
if (property.isDefaultProperty() && property.isNodeListProperty()) {
m_removeDefaultPropertyTransaction = beginRewriterTransaction();
m_removeDefaultPropertyTransaction = beginRewriterTransaction(QByteArrayLiteral("RewriterView::propertiesAboutToBeRemoved"));
foreach (const ModelNode &node, property.toNodeListProperty().toModelNodeList()) {
modelToTextMerger()->nodeRemoved(node, property.toNodeAbstractProperty(), AbstractView::NoAdditionalChanges);
......
......@@ -35,13 +35,29 @@
namespace QmlDesigner {
QList<QByteArray> RewriterTransaction::m_identifierList;
bool RewriterTransaction::m_activeIdentifier = !qgetenv("QML_DESIGNER_TRACE_REWRITER_TRANSACTION").isEmpty();
RewriterTransaction::RewriterTransaction() : m_valid(false)
{
}
RewriterTransaction::RewriterTransaction(AbstractView *_view) : m_view(_view), m_valid(true)
RewriterTransaction::RewriterTransaction(AbstractView *_view, const QByteArray &identifier)
: m_view(_view),
m_identifier(identifier),
m_valid(true)
{
Q_ASSERT(view());
static int identifierNumber = 0;
m_identifierNumber = identifierNumber++;
if (m_activeIdentifier) {
qDebug() << "Begin RewriterTransaction:" << m_identifier << m_identifierNumber;
m_identifierList.append(m_identifier + QByteArrayLiteral("-") + QByteArray::number(m_identifierNumber));
}
view()->emitRewriterBeginTransaction();
}
......@@ -60,6 +76,12 @@ void RewriterTransaction::commit()
if (m_valid) {
m_valid = false;
view()->emitRewriterEndTransaction();
if (m_activeIdentifier) {
qDebug() << "Commit RewriterTransaction:" << m_identifier << m_identifierNumber;
bool success = m_identifierList.removeOne(m_identifier + QByteArrayLiteral("-") + QByteArray::number(m_identifierNumber));
Q_ASSERT(success);
}
}
}
......@@ -70,6 +92,11 @@ void RewriterTransaction::rollback()
m_valid = false;
view()->emitRewriterEndTransaction();
QmlDesignerPlugin::instance()->currentDesignDocument()->undo();
if (m_activeIdentifier) {
qDebug() << "Rollback RewriterTransaction:" << m_identifier << m_identifierNumber;
m_identifierList.removeOne(m_identifier + QByteArrayLiteral("-") + QByteArray::number(m_identifierNumber));
}
}
}
......@@ -84,6 +111,8 @@ RewriterTransaction::RewriterTransaction(const RewriterTransaction &other)
if (&other != this) {
m_valid = other.m_valid;
m_view = other.m_view;
m_identifier = other.m_identifier;
m_identifierNumber = other.m_identifierNumber;
other.m_valid = false;
}
}
......@@ -93,6 +122,8 @@ RewriterTransaction& RewriterTransaction::operator=(const RewriterTransaction &o
if (!m_valid && (&other != this)) {
m_valid = other.m_valid;
m_view = other.m_view;
m_identifier = other.m_identifier;
m_identifierNumber = other.m_identifierNumber;
other.m_valid = false;
}
......
......@@ -42,7 +42,7 @@ class QMLDESIGNERCORE_EXPORT RewriterTransaction
{
public:
RewriterTransaction();
RewriterTransaction(AbstractView *view);
RewriterTransaction(AbstractView *view, const QByteArray &identifier);
~RewriterTransaction();
void commit();
void rollback();
......@@ -55,7 +55,11 @@ protected:
AbstractView *view();
private:
QWeakPointer<AbstractView> m_view;
QByteArray m_identifier;
mutable bool m_valid;
int m_identifierNumber;
static QList<QByteArray> m_identifierList;
static bool m_activeIdentifier;
};
} //QmlDesigner
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment