summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp13
2 files changed, 15 insertions, 2 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index d36d163..b9d231e 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -3600,8 +3600,8 @@ void QDeclarativeItem::setSize(const QSizeF &size)
bool QDeclarativeItem::hasActiveFocus() const
{
Q_D(const QDeclarativeItem);
- return focusItem() == this ||
- (d->flags & QGraphicsItem::ItemIsFocusScope && focusItem() != 0);
+ return (focusItem() && focusItem()->isVisible()) && (focusItem() == this ||
+ (d->flags & QGraphicsItem::ItemIsFocusScope && focusItem() != 0));
}
/*!
diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
index 362a8ff..2fdeb71 100644
--- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
+++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
@@ -90,6 +90,7 @@ private slots:
void testQtQuick11Attributes();
void testQtQuick11Attributes_data();
void qtbug_16871();
+ void qtbug_21045();
private:
QDeclarativeEngine engine;
};
@@ -1238,6 +1239,18 @@ void tst_QDeclarativeItem::qtbug_16871()
delete o;
}
+void tst_QDeclarativeItem::qtbug_21045()
+{
+ QDeclarativeComponent component(&engine);
+ QGraphicsScene scene;
+ component.setData("import QtQuick 1.1\nItem{visible: false; focus: true}", QUrl::fromLocalFile("file:"));
+ QObject *o = component.create();
+ QDeclarativeItem* i = qobject_cast<QDeclarativeItem*>(o);
+ QVERIFY(i);
+ scene.addItem(i);
+ QVERIFY(!i->hasActiveFocus());
+}
+
QTEST_MAIN(tst_QDeclarativeItem)
#include "tst_qdeclarativeitem.moc"