summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/fx/qfxanchors.cpp14
-rw-r--r--tests/auto/declarative/anchors/tst_anchors.cpp19
2 files changed, 18 insertions, 15 deletions
diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp
index bd5520a..09d6178 100644
--- a/src/declarative/fx/qfxanchors.cpp
+++ b/src/declarative/fx/qfxanchors.cpp
@@ -325,6 +325,10 @@ QFxItem *QFxAnchors::fill() const
void QFxAnchors::setFill(QFxItem *f)
{
Q_D(QFxAnchors);
+ if (f != d->item->itemParent() && f->itemParent() != d->item->itemParent()){
+ qmlInfo(d->item) << "Can't anchor to an item that isn't a parent or sibling.";
+ return;
+ }
d->remDepend(d->fill);
d->fill = f;
d->addDepend(d->fill);
@@ -847,7 +851,10 @@ bool QFxAnchorsPrivate::checkHAnchorValid(QFxAnchorLine anchor) const
if (anchor.anchorLine & QFxAnchorLine::Vertical_Mask) {
qmlInfo(item) << "Can't anchor a horizontal edge to a vertical edge.";
return false;
- }else if (anchor.item == item){
+ } else if (anchor.item != item->itemParent() && anchor.item->itemParent() != item->itemParent()){
+ qmlInfo(item) << "Can't anchor to an item that isn't a parent or sibling.";
+ return false;
+ } else if (anchor.item == item){
qmlInfo(item) << "Can't anchor item to self.";
return false;
}
@@ -878,7 +885,10 @@ bool QFxAnchorsPrivate::checkVAnchorValid(QFxAnchorLine anchor) const
if (anchor.anchorLine & QFxAnchorLine::Horizontal_Mask) {
qmlInfo(item) << "Can't anchor a vertical edge to a horizontal edge.";
return false;
- }else if (anchor.item == item){
+ } else if (anchor.item != item->itemParent() && anchor.item->itemParent() != item->itemParent()){
+ qmlInfo(item) << "Can't anchor to an item that isn't a parent or sibling.";
+ return false;
+ } else if (anchor.item == item){
qmlInfo(item) << "Can't anchor item to self.";
return false;
}
diff --git a/tests/auto/declarative/anchors/tst_anchors.cpp b/tests/auto/declarative/anchors/tst_anchors.cpp
index 587b4ab..abe6d96 100644
--- a/tests/auto/declarative/anchors/tst_anchors.cpp
+++ b/tests/auto/declarative/anchors/tst_anchors.cpp
@@ -95,9 +95,7 @@ void tst_anchors::loops()
view->setUrl(QUrl("file://" SRCDIR "/data/loop1.qml"));
- //### ignoreMessage doesn't seem to work
- //QTest::ignoreMessage(QtWarningMsg, "QML QFxText (unknown location): Anchor loop detected on horizontal anchor.");
- //QTest::ignoreMessage(QtWarningMsg, "QML QFxText (unknown location): Anchor loop detected on horizontal anchor.");
+ QTest::ignoreMessage(QtWarningMsg, "QML QFxText (unknown location): Possible anchor loop detected on horizontal anchor. "); //x5
view->execute();
qApp->processEvents();
@@ -109,9 +107,7 @@ void tst_anchors::loops()
view->setUrl(QUrl("file://" SRCDIR "/data/loop2.qml"));
- //### ignoreMessage doesn't seem to work here
- //QTest::ignoreMessage(QtWarningMsg, "QML QFxImage (unknown location): Anchor loop detected on horizontal anchor.");
- //QTest::ignoreMessage(QtWarningMsg, "QML QFxImage (unknown location): Anchor loop detected on horizontal anchor.");
+ QTest::ignoreMessage(QtWarningMsg, "QML QFxImage (unknown location): Possible anchor loop detected on horizontal anchor. "); //x3
view->execute();
qApp->processEvents();
@@ -126,8 +122,7 @@ void tst_anchors::illegalSets()
view->setUrl(QUrl("file://" SRCDIR "/data/illegal1.qml"));
- //### ignoreMessage doesn't seem to work
- //QTest::ignoreMessage(QtWarningMsg, "QML QFxRect (unknown location): Can't specify left, right, and hcenter anchors.");
+ QTest::ignoreMessage(QtWarningMsg, "QML QFxRect (unknown location): Can't specify left, right, and hcenter anchors. ");
view->execute();
qApp->processEvents();
@@ -139,8 +134,7 @@ void tst_anchors::illegalSets()
view->setUrl(QUrl("file://" SRCDIR "/data/illegal2.qml"));
- //### ignoreMessage doesn't seem to work here
- //QTest::ignoreMessage(QtWarningMsg, "QML QFxText (unknown location): Baseline anchor can't be used in conjunction with top, bottom, or vcenter anchors.");
+ QTest::ignoreMessage(QtWarningMsg, "QML QFxText (unknown location): Baseline anchor can't be used in conjunction with top, bottom, or vcenter anchors. ");
view->execute();
//qApp->processEvents();
@@ -152,10 +146,9 @@ void tst_anchors::illegalSets()
view->setUrl(QUrl("file://" SRCDIR "/data/illegal3.qml"));
- //### ignoreMessage doesn't seem to work here
- //QTest::ignoreMessage(QtWarningMsg, "Can't anchor to an item that isn't a parent or sibling.");
+ QTest::ignoreMessage(QtWarningMsg, "QML QFxRect (unknown location): Can't anchor to an item that isn't a parent or sibling. ");
view->execute();
- qApp->processEvents();
+ //qApp->processEvents();
delete view;
}