summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-11-30 15:06:38 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-11-30 15:06:38 (GMT)
commitbb1a6cd1e9d6d00e8d70f665ca223261e9eda06e (patch)
treeb65be7919d3eb5e0b6fd63c6127234a79bd9e262
parente42d95d4e9d0dc547c604939f88de95180e74fa0 (diff)
parent840ffbd6187fe2573d8c00481120d4cf30aed351 (diff)
downloadQt-bb1a6cd1e9d6d00e8d70f665ca223261e9eda06e.zip
Qt-bb1a6cd1e9d6d00e8d70f665ca223261e9eda06e.tar.gz
Qt-bb1a6cd1e9d6d00e8d70f665ca223261e9eda06e.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: Ensure header is considered when positioning content with snapping. Fix integer overflow in QDeclarativeItemPrivate::origin enumeration Correct ownership semantics for QObject derived types Correctly handle CppOwnership even when a QDeclarativeData doesn't exist Fix Browser.qml warnings Document which header to include for qmlRegister functions. Don't draw null pixmap in QDeclarativeImage paint function Fix id documentation Link to List Properties docs from QML Intro page
-rw-r--r--doc/src/declarative/extending.qdoc2
-rw-r--r--doc/src/declarative/qdeclarativeintro.qdoc6
-rw-r--r--doc/src/declarative/qtdeclarative.qdoc16
-rw-r--r--doc/src/snippets/declarative/qtbinding/newelements/imageviewer.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp37
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp6
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp4
-rw-r--r--src/declarative/qml/qdeclarativeobjectscriptclass.cpp11
-rw-r--r--src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp83
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp30
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/header.qml31
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp31
-rw-r--r--tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp12
-rw-r--r--tools/qml/browser/Browser.qml4
18 files changed, 253 insertions, 30 deletions
diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc
index 5c1b977..740f7d1 100644
--- a/doc/src/declarative/extending.qdoc
+++ b/doc/src/declarative/extending.qdoc
@@ -75,6 +75,8 @@ constructor.
\endquotation
+#include <QtDeclarative> to use qmlRegisterType().
+
Types can be registered by libraries, application code, or by plugins
(see QDeclarativeExtensionPlugin).
diff --git a/doc/src/declarative/qdeclarativeintro.qdoc b/doc/src/declarative/qdeclarativeintro.qdoc
index 1d807e3..4e41fda 100644
--- a/doc/src/declarative/qdeclarativeintro.qdoc
+++ b/doc/src/declarative/qdeclarativeintro.qdoc
@@ -186,7 +186,7 @@ Item {
\section3 The \c id property
Each object can be given a special unique property called an \e id. No other object within the
-same \l{QML Documents}{QML document} can have the same \c id value. Assigning an id enables the object
+same QML component (see \l{QML Documents}) can have the same \c id value. Assigning an id enables the object
to be referred to by other objects and scripts.
The first Rectangle element below has an \e id, "myRect". The second Rectangle element defines its
@@ -233,6 +233,10 @@ Image {
}
\endcode
+Items in the list can be accessed by index. See the \l{list}{list type} documentation
+for more details about list properties and their available operations.
+
+
\section2 Default properties
Each object type can specify one of its list or object properties as its default property.
diff --git a/doc/src/declarative/qtdeclarative.qdoc b/doc/src/declarative/qtdeclarative.qdoc
index f2b2032..b0c6e06 100644
--- a/doc/src/declarative/qtdeclarative.qdoc
+++ b/doc/src/declarative/qtdeclarative.qdoc
@@ -57,6 +57,8 @@
\relates QDeclarativeEngine
Equivalent to \c Q_DECLARE_METATYPE(TYPE) and \c Q_DECLARE_METATYPE(QDeclarativeListProperty<TYPE>)
+
+ #include <QtDeclarative> to use this macro.
*/
/*!
@@ -68,6 +70,8 @@
Current the only supported type info is \c QML_HAS_ATTACHED_PROPERTIES which
declares that the \a Type supports \l {Attached Properties}.
+
+ #include <QtDeclarative> to use this macro.
*/
@@ -86,6 +90,10 @@
"com.mycompany.qmlcomponents":
\code
+ #include <QtDeclarative>
+
+ ...
+
qmlRegisterType<MySliderItem>("com.mycompany.qmlcomponents", 1, 0, "Slider");
\endcode
@@ -119,6 +127,8 @@
Returns the QML type id.
+ #include <QtDeclarative> to use this function.
+
\sa qmlRegisterTypeNotAvailable()
*/
@@ -154,6 +164,8 @@
Without this, a generic "Game is not a type" message would be given.
+ #include <QtDeclarative> to use this function.
+
\sa qmlRegisterUncreatableType()
*/
@@ -166,6 +178,8 @@
system. Instances of this type cannot be created from the QML
system.
+ #include <QtDeclarative> to use this function.
+
Returns the QML type id.
*/
@@ -176,5 +190,7 @@
This template function registers the C++ type in the QML system
under the name \a typeName.
+ #include <QtDeclarative> to use this function.
+
Returns the QML type id.
*/
diff --git a/doc/src/snippets/declarative/qtbinding/newelements/imageviewer.h b/doc/src/snippets/declarative/qtbinding/newelements/imageviewer.h
index fd9db5e..cec9757 100644
--- a/doc/src/snippets/declarative/qtbinding/newelements/imageviewer.h
+++ b/doc/src/snippets/declarative/qtbinding/newelements/imageviewer.h
@@ -37,10 +37,10 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+//![0]
#include <QtCore>
#include <QtDeclarative>
-//![0]
class ImageViewer : public QDeclarativeItem
{
Q_OBJECT
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 6f38f63..4454284 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -219,12 +219,8 @@ public:
}
} else {
qreal pos = (modelIndex / columns) * rowSize();
- if (header) {
- qreal headerSize = flow == QDeclarativeGridView::LeftToRight
- ? header->item->height()
- : header->item->width();
- pos += headerSize;
- }
+ if (header)
+ pos += headerSize();
return pos;
}
return 0;
@@ -291,11 +287,9 @@ public:
if (item->index == -1)
continue;
qreal itemTop = item->rowPos();
- if (item->index == model->count()-1 || (itemTop+rowSize()/2 >= pos))
+ if (itemTop+rowSize()/2 >= pos && itemTop - rowSize()/2 <= pos)
return item;
}
- if (visibleItems.count() && visibleItems.first()->rowPos() <= pos)
- return visibleItems.first();
return 0;
}
@@ -315,6 +309,16 @@ public:
return index;
}
+ qreal headerSize() const {
+ if (!header)
+ return 0.0;
+
+ return flow == QDeclarativeGridView::LeftToRight
+ ? header->item->height()
+ : header->item->width();
+ }
+
+
virtual void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) {
Q_Q(const QDeclarativeGridView);
QDeclarativeFlickablePrivate::itemGeometryChanged(item, newGeometry, oldGeometry);
@@ -878,14 +882,11 @@ void QDeclarativeGridViewPrivate::updateHeader()
if (header) {
if (visibleItems.count()) {
qreal startPos = startPosition();
- qreal headerSize = flow == QDeclarativeGridView::LeftToRight
- ? header->item->height()
- : header->item->width();
if (visibleIndex == 0) {
- header->setPosition(0, startPos - headerSize);
+ header->setPosition(0, startPos - headerSize());
} else {
- if (position() <= startPos || header->rowPos() > startPos - headerSize)
- header->setPosition(0, startPos - headerSize);
+ if (position() <= startPos || header->rowPos() > startPos - headerSize())
+ header->setPosition(0, startPos - headerSize());
}
} else {
header->setPosition(0, 0);
@@ -920,10 +921,14 @@ void QDeclarativeGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m
qreal bottomPos = qMax(bottomItem->rowPos() - highlightRangeEnd, -minExtent);
pos = qAbs(data.move + topPos) < qAbs(data.move + bottomPos) ? topPos : bottomPos;
} else if (topItem) {
- pos = qMax(qMin(topItem->rowPos() - highlightRangeStart, -maxExtent), -minExtent);
+ if (topItem->index == 0 && header && position()+highlightRangeStart < header->rowPos()+headerSize()/2)
+ pos = header->rowPos() - highlightRangeStart;
+ else
+ pos = qMax(qMin(topItem->rowPos() - highlightRangeStart, -maxExtent), -minExtent);
} else if (bottomItem) {
pos = qMax(qMin(bottomItem->rowPos() - highlightRangeStart, -maxExtent), -minExtent);
} else {
+ QDeclarativeFlickablePrivate::fixup(data, minExtent, maxExtent);
fixupDuration = oldDuration;
return;
}
diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp
index 3b08a9b..aa74716 100644
--- a/src/declarative/graphicsitems/qdeclarativeimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp
@@ -461,7 +461,7 @@ QRectF QDeclarativeImage::boundingRect() const
void QDeclarativeImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{
Q_D(QDeclarativeImage);
- if (d->pix.isNull())
+ if (d->pix.pixmap().isNull() )
return;
bool oldAA = p->testRenderHint(QPainter::Antialiasing);
diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h
index f85fa27..d8635b9 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h
@@ -259,7 +259,7 @@ public:
QDeclarativeStateGroup *_states();
QDeclarativeStateGroup *_stateGroup;
- QDeclarativeItem::TransformOrigin origin:4;
+ QDeclarativeItem::TransformOrigin origin:5;
bool widthValid:1;
bool heightValid:1;
bool componentComplete:1;
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index 450b6af..d1f52be 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -1185,10 +1185,14 @@ void QDeclarativeListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m
FxListItem *bottomItem = snapItemAt(position()+highlightRangeEnd);
qreal pos;
if (topItem) {
- pos = qMax(qMin(topItem->position() - highlightRangeStart, -maxExtent), -minExtent);
+ if (topItem->index == 0 && header && position()+highlightRangeStart < header->position()+header->size()/2)
+ pos = header->position() - highlightRangeStart;
+ else
+ pos = qMax(qMin(topItem->position() - highlightRangeStart, -maxExtent), -minExtent);
} else if (bottomItem) {
pos = qMax(qMin(bottomItem->position() - highlightRangeStart, -maxExtent), -minExtent);
} else {
+ QDeclarativeFlickablePrivate::fixup(data, minExtent, maxExtent);
fixupDuration = oldDuration;
return;
}
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index c646302..add1ab7 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -897,9 +897,7 @@ void QDeclarativeEngine::setObjectOwnership(QObject *object, ObjectOwnership own
if (!object)
return;
- // No need to do anything if CppOwnership and there is no QDeclarativeData as
- // the current ownership must be CppOwnership
- QDeclarativeData *ddata = QDeclarativeData::get(object, ownership == JavaScriptOwnership);
+ QDeclarativeData *ddata = QDeclarativeData::get(object, true);
if (!ddata)
return;
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
index eff59df..b0bc5bb 100644
--- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
@@ -69,7 +69,7 @@ struct ObjectData : public QScriptDeclarativeClass::Object {
virtual ~ObjectData() {
if (object && !object->parent()) {
QDeclarativeData *ddata = QDeclarativeData::get(object, false);
- if (ddata && !ddata->indestructible && 0 == --ddata->objectDataRefCount)
+ if (ddata && !ddata->indestructible && 0 == --ddata->objectDataRefCount)
object->deleteLater();
}
}
@@ -808,7 +808,14 @@ QScriptDeclarativeClass::Value MetaCallArgument::toValue(QDeclarativeEngine *e)
}
return QScriptDeclarativeClass::Value(engine, rv);
} else if (type == -1 || type == qMetaTypeId<QVariant>()) {
- return QScriptDeclarativeClass::Value(engine, QDeclarativeEnginePrivate::get(e)->scriptValueFromVariant(*((QVariant *)&data)));
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(e);
+ QScriptValue rv = ep->scriptValueFromVariant(*((QVariant *)&data));
+ if (rv.isQObject()) {
+ QObject *object = rv.toQObject();
+ if (object)
+ QDeclarativeData::get(object, true)->setImplicitDestructible();
+ }
+ return QScriptDeclarativeClass::Value(engine, rv);
} else {
return QScriptDeclarativeClass::Value();
}
diff --git a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp
index abab33c..9c71004 100644
--- a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp
+++ b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp
@@ -279,7 +279,7 @@ void QDeclarativeFolderListModel::classBegin()
void QDeclarativeFolderListModel::componentComplete()
{
- if (!d->folder.isValid() || !QDir().exists(d->folder.toLocalFile()))
+ if (!d->folder.isValid() || d->folder.toLocalFile().isEmpty() || !QDir().exists(d->folder.toLocalFile()))
setFolder(QUrl(QLatin1String("file://")+QDir::currentPath()));
if (!d->folderIndex.isValid())
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 14755f32..77fab91 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -135,6 +135,8 @@ private slots:
void scriptConnect();
void scriptDisconnect();
void ownership();
+ void cppOwnershipReturnValue();
+ void ownershipCustomReturnValue();
void qlistqobjectMethods();
void strictlyEquals();
void compiled();
@@ -2100,6 +2102,87 @@ void tst_qdeclarativeecmascript::ownership()
}
}
+class CppOwnershipReturnValue : public QObject
+{
+ Q_OBJECT
+public:
+ CppOwnershipReturnValue() : value(0) {}
+ ~CppOwnershipReturnValue() { delete value; }
+
+ Q_INVOKABLE QObject *create() {
+ Q_ASSERT(value == 0);
+
+ value = new QObject;
+ QDeclarativeEngine::setObjectOwnership(value, QDeclarativeEngine::CppOwnership);
+ return value;
+ }
+
+ Q_INVOKABLE MyQmlObject *createQmlObject() {
+ Q_ASSERT(value == 0);
+
+ MyQmlObject *rv = new MyQmlObject;
+ value = rv;
+ return rv;
+ }
+
+ QPointer<QObject> value;
+};
+
+// QTBUG-15695.
+// Test setObjectOwnership(CppOwnership) works even when there is no QDeclarativeData
+void tst_qdeclarativeecmascript::cppOwnershipReturnValue()
+{
+ CppOwnershipReturnValue source;
+
+ {
+ QDeclarativeEngine engine;
+ engine.rootContext()->setContextProperty("source", &source);
+
+ QVERIFY(source.value == 0);
+
+ QDeclarativeComponent component(&engine);
+ component.setData("import QtQuick 1.0\nQtObject {\nComponent.onCompleted: { var a = source.create(); }\n}\n", QUrl());
+
+ QObject *object = component.create();
+
+ QVERIFY(object != 0);
+ QVERIFY(source.value != 0);
+
+ delete object;
+ }
+
+ QCoreApplication::instance()->processEvents(QEventLoop::DeferredDeletion);
+
+ QVERIFY(source.value != 0);
+}
+
+// QTBUG-15697
+void tst_qdeclarativeecmascript::ownershipCustomReturnValue()
+{
+ CppOwnershipReturnValue source;
+
+ {
+ QDeclarativeEngine engine;
+ engine.rootContext()->setContextProperty("source", &source);
+
+ QVERIFY(source.value == 0);
+
+ QDeclarativeComponent component(&engine);
+ component.setData("import QtQuick 1.0\nQtObject {\nComponent.onCompleted: { var a = source.createQmlObject(); }\n}\n", QUrl());
+
+ QObject *object = component.create();
+
+ QVERIFY(object != 0);
+ QVERIFY(source.value != 0);
+
+ delete object;
+ }
+
+ QCoreApplication::instance()->processEvents(QEventLoop::DeferredDeletion);
+
+ QVERIFY(source.value == 0);
+}
+
class QListQObjectMethodsObject : public QObject
{
Q_OBJECT
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index 327bba2..7998e30 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -1263,7 +1263,7 @@ void tst_QDeclarativeGridView::header()
QDeclarativeView *canvas = createView();
TestModel model;
- for (int i = 0; i < 7; i++)
+ for (int i = 0; i < 30; i++)
model.addItem("Item" + QString::number(i), "");
QDeclarativeContext *ctxt = canvas->rootContext();
diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
index bf779ad..447210d 100644
--- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
+++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
@@ -87,6 +87,7 @@ private slots:
void noLoading();
void paintedWidthHeight();
void sourceSize_QTBUG_14303();
+ void nullPixmapPaint();
private:
template<typename T>
@@ -540,6 +541,35 @@ void tst_qdeclarativeimage::sourceSize_QTBUG_14303()
QTRY_COMPARE(sourceSizeSpy.count(), 2);
}
+static int numberOfWarnings = 0;
+static void checkWarnings(QtMsgType, const char *)
+{
+ numberOfWarnings++;
+}
+
+// QTBUG-15690
+void tst_qdeclarativeimage::nullPixmapPaint()
+{
+ QString componentStr = QString("import QtQuick 1.0\nImage { width: 10; height:10; fillMode: Image.PreserveAspectFit; source: \"")
+ + SERVER_ADDR + QString("/no-such-file.png\" }");
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeImage *image = qobject_cast<QDeclarativeImage*>(component.create());
+
+ QTRY_VERIFY(image != 0);
+
+ QtMsgHandler previousMsgHandler = qInstallMsgHandler(checkWarnings);
+
+ QPixmap pm(100, 100);
+ QPainter p(&pm);
+
+ // used to print "QTransform::translate with NaN called"
+ image->paint(&p, 0, 0);
+ qInstallMsgHandler(previousMsgHandler);
+ QVERIFY(numberOfWarnings == 0);
+ delete image;
+}
+
/*
Find an item with the specified objectName. If index is supplied then the
item must also evaluate the {index} expression equal to index
diff --git a/tests/auto/declarative/qdeclarativelistview/data/header.qml b/tests/auto/declarative/qdeclarativelistview/data/header.qml
new file mode 100644
index 0000000..6da996e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistview/data/header.qml
@@ -0,0 +1,31 @@
+import QtQuick 1.0
+
+Rectangle {
+ width: 240
+ height: 320
+ color: "#ffffff"
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+ objectName: "wrapper"
+ height: 30
+ width: 240
+ Text {
+ text: index
+ }
+ color: ListView.isCurrentItem ? "lightsteelblue" : "white"
+ }
+ }
+ ListView {
+ id: list
+ objectName: "list"
+ focus: true
+ width: 240
+ height: 320
+ snapMode: ListView.SnapToItem
+ model: testModel
+ delegate: myDelegate
+ header: Text { objectName: "header"; text: "Header"; height: 10 }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index 37d836d..295a75d 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -98,6 +98,7 @@ private slots:
void QTBUG_9791();
void manualHighlight();
void QTBUG_11105();
+ void header();
void footer();
void resizeView();
void sizeLessThan1();
@@ -1661,6 +1662,36 @@ void tst_QDeclarativeListView::QTBUG_11105()
delete canvas;
}
+void tst_QDeclarativeListView::header()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/header.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QDeclarativeText *header = findItem<QDeclarativeText>(contentItem, "header");
+ QVERIFY(header);
+ QCOMPARE(header->y(), 0.0);
+
+ QCOMPARE(listview->contentY(), 0.0);
+
+ model.clear();
+ QTRY_COMPARE(header->y(), 0.0);
+}
+
void tst_QDeclarativeListView::footer()
{
QDeclarativeView *canvas = createView();
diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
index 21c7197..f19eb03 100644
--- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
+++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
@@ -238,13 +238,25 @@ void tst_QDeclarativeViewer::loading()
delete viewer;
}
+static int numberOfWarnings = 0;
+static void checkWarnings(QtMsgType, const char *)
+{
+ numberOfWarnings++;
+}
+
void tst_QDeclarativeViewer::fileBrowser()
{
+ QtMsgHandler previousMsgHandler = qInstallMsgHandler(checkWarnings);
QDeclarativeViewer *viewer = new QDeclarativeViewer();
QVERIFY(viewer);
viewer->setUseNativeFileBrowser(false);
viewer->openFile();
viewer->show();
+ QCoreApplication::processEvents();
+ qInstallMsgHandler(previousMsgHandler);
+
+ // QTBUG-15720
+ QVERIFY(numberOfWarnings == 0);
QApplication::setActiveWindow(viewer);
QTest::qWaitForWindowShown(viewer);
diff --git a/tools/qml/browser/Browser.qml b/tools/qml/browser/Browser.qml
index ebed72f..b9573da 100644
--- a/tools/qml/browser/Browser.qml
+++ b/tools/qml/browser/Browser.qml
@@ -180,7 +180,7 @@ Rectangle {
GradientStop { id: t1; position: 0.0; color: palette.highlight }
GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) }
}
- width: view1.currentItem.width
+ width: view1.currentItem == null ? 0 : view1.currentItem.width
}
highlightMoveSpeed: 1000
pressDelay: 100
@@ -230,7 +230,7 @@ Rectangle {
GradientStop { id: t1; position: 0.0; color: palette.highlight }
GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) }
}
- width: view1.currentItem.width
+ width: view1.currentItem == null ? 0 : view1.currentItem.width
}
highlightMoveSpeed: 1000
pressDelay: 100