forked from qt-creator/qt-creator
QmlDesigner: Add try catch blocks for anchoring
There have been casual unreproducible crashes. This kind of code should be replaced by using lambdas in master. Change-Id: I5b44a4c7b013f70a012c22ff9610e5579b165ab4 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -24,7 +24,9 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmlanchorbindingproxy.h"
|
||||
#include "abstractview.h"
|
||||
|
||||
#include <exception.h>
|
||||
#include <abstractview.h>
|
||||
#include <qmlanchors.h>
|
||||
#include <nodeabstractproperty.h>
|
||||
#include <variantproperty.h>
|
||||
@@ -359,6 +361,7 @@ void QmlAnchorBindingProxy::setTopTarget(const QString &target)
|
||||
if (!newTarget.isValid())
|
||||
return;
|
||||
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::setTopTarget"));
|
||||
|
||||
@@ -368,6 +371,11 @@ void QmlAnchorBindingProxy::setTopTarget(const QString &target)
|
||||
|
||||
anchorTop();
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
|
||||
emit topTargetChanged();
|
||||
}
|
||||
|
||||
@@ -385,6 +393,7 @@ void QmlAnchorBindingProxy::setBottomTarget(const QString &target)
|
||||
if (!newTarget.isValid())
|
||||
return;
|
||||
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::setBottomTarget"));
|
||||
|
||||
@@ -392,6 +401,11 @@ void QmlAnchorBindingProxy::setBottomTarget(const QString &target)
|
||||
setDefaultRelativeBottomTarget();
|
||||
anchorBottom();
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
|
||||
emit bottomTargetChanged();
|
||||
}
|
||||
|
||||
@@ -408,6 +422,7 @@ void QmlAnchorBindingProxy::setLeftTarget(const QString &target)
|
||||
if (!newTarget.isValid())
|
||||
return;
|
||||
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::setLeftTarget"));
|
||||
|
||||
@@ -415,6 +430,11 @@ void QmlAnchorBindingProxy::setLeftTarget(const QString &target)
|
||||
setDefaultRelativeLeftTarget();
|
||||
anchorLeft();
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
|
||||
emit leftTargetChanged();
|
||||
}
|
||||
|
||||
@@ -431,6 +451,7 @@ void QmlAnchorBindingProxy::setRightTarget(const QString &target)
|
||||
if (!newTarget.isValid())
|
||||
return;
|
||||
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::setRightTarget"));
|
||||
|
||||
@@ -438,6 +459,11 @@ void QmlAnchorBindingProxy::setRightTarget(const QString &target)
|
||||
setDefaultRelativeRightTarget();
|
||||
anchorRight();
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
|
||||
emit rightTargetChanged();
|
||||
}
|
||||
|
||||
@@ -454,12 +480,18 @@ void QmlAnchorBindingProxy::setVerticalTarget(const QString &target)
|
||||
if (!newTarget.isValid())
|
||||
return;
|
||||
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::setVerticalTarget"));
|
||||
|
||||
m_verticalTarget = newTarget;
|
||||
anchorVertical();
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
|
||||
emit verticalTargetChanged();
|
||||
}
|
||||
|
||||
@@ -476,11 +508,17 @@ void QmlAnchorBindingProxy::setHorizontalTarget(const QString &target)
|
||||
if (!newTarget.isValid())
|
||||
return;
|
||||
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::setHorizontalTarget"));
|
||||
|
||||
m_horizontalTarget = newTarget;
|
||||
anchorHorizontal();
|
||||
anchorHorizontal();\
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
|
||||
emit horizontalTargetChanged();
|
||||
}
|
||||
@@ -493,6 +531,7 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetTop(QmlAnchorBindingProxy::Re
|
||||
if (target == m_relativeTopTarget)
|
||||
return;
|
||||
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetTop"));
|
||||
|
||||
@@ -500,6 +539,11 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetTop(QmlAnchorBindingProxy::Re
|
||||
|
||||
anchorTop();
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
|
||||
emit relativeAnchorTargetTopChanged();
|
||||
}
|
||||
|
||||
@@ -511,13 +555,20 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetBottom(QmlAnchorBindingProxy:
|
||||
if (target == m_relativeBottomTarget)
|
||||
return;
|
||||
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetBottom"));
|
||||
|
||||
m_relativeBottomTarget = target;
|
||||
|
||||
|
||||
anchorBottom();
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
|
||||
emit relativeAnchorTargetBottomChanged();
|
||||
}
|
||||
|
||||
@@ -529,6 +580,7 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetLeft(QmlAnchorBindingProxy::R
|
||||
if (target == m_relativeLeftTarget)
|
||||
return;
|
||||
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetLeft"));
|
||||
|
||||
@@ -536,6 +588,11 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetLeft(QmlAnchorBindingProxy::R
|
||||
|
||||
anchorLeft();
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
|
||||
emit relativeAnchorTargetLeftChanged();
|
||||
}
|
||||
|
||||
@@ -547,6 +604,7 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetRight(QmlAnchorBindingProxy::
|
||||
if (target == m_relativeRightTarget)
|
||||
return;
|
||||
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetRight"));
|
||||
|
||||
@@ -554,6 +612,11 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetRight(QmlAnchorBindingProxy::
|
||||
|
||||
anchorRight();
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
|
||||
emit relativeAnchorTargetRightChanged();
|
||||
|
||||
}
|
||||
@@ -566,6 +629,7 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetVertical(QmlAnchorBindingProx
|
||||
if (target == m_relativeVerticalTarget)
|
||||
return;
|
||||
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetVertical"));
|
||||
|
||||
@@ -573,6 +637,11 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetVertical(QmlAnchorBindingProx
|
||||
|
||||
anchorVertical();
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
|
||||
emit relativeAnchorTargetVerticalChanged();
|
||||
}
|
||||
|
||||
@@ -584,6 +653,7 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetHorizontal(QmlAnchorBindingPr
|
||||
if (target == m_relativeHorizontalTarget)
|
||||
return;
|
||||
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetHorizontal"));
|
||||
|
||||
@@ -591,6 +661,11 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetHorizontal(QmlAnchorBindingPr
|
||||
|
||||
anchorHorizontal();
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
|
||||
emit relativeAnchorTargetHorizontalChanged();
|
||||
}
|
||||
|
||||
@@ -635,6 +710,8 @@ int QmlAnchorBindingProxy::indexOfPossibleTargetItem(const QString &targetName)
|
||||
}
|
||||
|
||||
void QmlAnchorBindingProxy::resetLayout() {
|
||||
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::resetLayout"));
|
||||
|
||||
@@ -646,6 +723,11 @@ void QmlAnchorBindingProxy::resetLayout() {
|
||||
restoreProperty(modelNode(), "width");
|
||||
restoreProperty(modelNode(), "height");
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
|
||||
emit topAnchorChanged();
|
||||
emit bottomAnchorChanged();
|
||||
emit leftAnchorChanged();
|
||||
@@ -661,6 +743,7 @@ void QmlAnchorBindingProxy::setBottomAnchor(bool anchor)
|
||||
if (bottomAnchored() == anchor)
|
||||
return;
|
||||
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::setBottomAnchor"));
|
||||
|
||||
@@ -673,6 +756,11 @@ void QmlAnchorBindingProxy::setBottomAnchor(bool anchor)
|
||||
backupPropertyAndRemove(modelNode(), "height");
|
||||
}
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
|
||||
emit relativeAnchorTargetBottomChanged();
|
||||
emit bottomAnchorChanged();
|
||||
|
||||
@@ -688,6 +776,7 @@ void QmlAnchorBindingProxy::setLeftAnchor(bool anchor)
|
||||
if (leftAnchored() == anchor)
|
||||
return;
|
||||
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::setLeftAnchor"));
|
||||
|
||||
@@ -702,6 +791,11 @@ void QmlAnchorBindingProxy::setLeftAnchor(bool anchor)
|
||||
backupPropertyAndRemove(modelNode(), "width");
|
||||
}
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
|
||||
emit relativeAnchorTargetLeftChanged();
|
||||
emit leftAnchorChanged();
|
||||
if (hasAnchors() != anchor)
|
||||
@@ -716,6 +810,7 @@ void QmlAnchorBindingProxy::setRightAnchor(bool anchor)
|
||||
if (rightAnchored() == anchor)
|
||||
return;
|
||||
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::setRightAnchor"));
|
||||
|
||||
@@ -729,6 +824,11 @@ void QmlAnchorBindingProxy::setRightAnchor(bool anchor)
|
||||
backupPropertyAndRemove(modelNode(), "width");
|
||||
}
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
|
||||
emit relativeAnchorTargetRightChanged();
|
||||
emit rightAnchorChanged();
|
||||
|
||||
@@ -926,6 +1026,7 @@ void QmlAnchorBindingProxy::setTopAnchor(bool anchor)
|
||||
if (topAnchored() == anchor)
|
||||
return;
|
||||
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::setTopAnchor"));
|
||||
|
||||
@@ -939,6 +1040,10 @@ void QmlAnchorBindingProxy::setTopAnchor(bool anchor)
|
||||
if (bottomAnchored())
|
||||
backupPropertyAndRemove(modelNode(), "height");
|
||||
}
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
|
||||
emit relativeAnchorTargetTopChanged();
|
||||
emit topAnchorChanged();
|
||||
@@ -947,6 +1052,7 @@ void QmlAnchorBindingProxy::setTopAnchor(bool anchor)
|
||||
}
|
||||
|
||||
void QmlAnchorBindingProxy::removeTopAnchor() {
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::removeTopAnchor"));
|
||||
|
||||
@@ -956,9 +1062,14 @@ void QmlAnchorBindingProxy::removeTopAnchor() {
|
||||
restoreProperty(modelNode(), "y");
|
||||
restoreProperty(modelNode(), "height");
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
}
|
||||
|
||||
void QmlAnchorBindingProxy::removeBottomAnchor() {
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::removeBottomAnchor"));
|
||||
|
||||
@@ -967,9 +1078,15 @@ void QmlAnchorBindingProxy::removeBottomAnchor() {
|
||||
|
||||
|
||||
restoreProperty(modelNode(), "height");
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
}
|
||||
|
||||
void QmlAnchorBindingProxy::removeLeftAnchor() {
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::removeLeftAnchor"));
|
||||
|
||||
@@ -978,9 +1095,15 @@ void QmlAnchorBindingProxy::removeLeftAnchor() {
|
||||
|
||||
restoreProperty(modelNode(), "x");
|
||||
restoreProperty(modelNode(), "width");
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
}
|
||||
|
||||
void QmlAnchorBindingProxy::removeRightAnchor() {
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::removeRightAnchor"));
|
||||
|
||||
@@ -988,6 +1111,11 @@ void QmlAnchorBindingProxy::removeRightAnchor() {
|
||||
m_qmlItemNode.anchors().removeMargin(AnchorLineRight);
|
||||
|
||||
restoreProperty(modelNode(), "width");
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
}
|
||||
|
||||
void QmlAnchorBindingProxy::setVerticalCentered(bool centered)
|
||||
@@ -1000,6 +1128,7 @@ void QmlAnchorBindingProxy::setVerticalCentered(bool centered)
|
||||
|
||||
m_locked = true;
|
||||
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::setVerticalCentered"));
|
||||
|
||||
@@ -1012,6 +1141,10 @@ void QmlAnchorBindingProxy::setVerticalCentered(bool centered)
|
||||
anchorVertical();
|
||||
}
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
m_locked = false;
|
||||
|
||||
emit relativeAnchorTargetVerticalChanged();
|
||||
@@ -1028,6 +1161,7 @@ void QmlAnchorBindingProxy::setHorizontalCentered(bool centered)
|
||||
|
||||
m_locked = true;
|
||||
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::setHorizontalCentered"));
|
||||
|
||||
@@ -1040,6 +1174,10 @@ void QmlAnchorBindingProxy::setHorizontalCentered(bool centered)
|
||||
anchorHorizontal();
|
||||
}
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
m_locked = false;
|
||||
|
||||
emit relativeAnchorTargetHorizontalChanged();
|
||||
@@ -1119,6 +1257,7 @@ bool QmlAnchorBindingProxy::horizontalCentered()
|
||||
void QmlAnchorBindingProxy::fill()
|
||||
{
|
||||
|
||||
try {
|
||||
RewriterTransaction transaction = beginRewriterTransaction(
|
||||
QByteArrayLiteral("QmlAnchorBindingProxy::fill"));
|
||||
|
||||
@@ -1138,6 +1277,11 @@ void QmlAnchorBindingProxy::fill()
|
||||
m_qmlItemNode.anchors().removeMargin(AnchorLineTop);
|
||||
m_qmlItemNode.anchors().removeMargin(AnchorLineBottom);
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Exception &e) {
|
||||
e.showException();
|
||||
}
|
||||
|
||||
emit topAnchorChanged();
|
||||
emit bottomAnchorChanged();
|
||||
emit leftAnchorChanged();
|
||||
|
Reference in New Issue
Block a user