From 3750d24175904916fe5ab8b1a76db956b1904e72 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 2 Sep 2011 09:14:33 +1000 Subject: Fix leak in bindings created by PropertyChanges. Change-Id: I1c7b575e1ace2b879dba130cd31e3ff8cf67260a Task-number: QTBUG-17770 Reviewed-by: Aaron Kennedy --- src/declarative/qml/qdeclarativebinding.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp index 689cd00..9359196 100644 --- a/src/declarative/qml/qdeclarativebinding.cpp +++ b/src/declarative/qml/qdeclarativebinding.cpp @@ -254,6 +254,8 @@ QDeclarativeBinding::createBinding(Identifier id, QObject *obj, QDeclarativeCont cdata = typeData->compiledData(); } QDeclarativeBinding *rv = cdata ? new QDeclarativeBinding((void*)cdata->datas.at(id).constData(), cdata, obj, ctxtdata, url, lineNumber, parent) : 0; + if (cdata) + cdata->release(); if (typeData) typeData->release(); return rv; -- cgit v0.12 From 8570c509f505a4b238905122645a80faa768adb5 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 2 Sep 2011 09:45:16 +1000 Subject: Fix leak in State element. If a state was destroyed while active, it would leak bindings. Task-number: QTBUG-21194 Reviewed-by: Aaron Kennedy --- src/declarative/util/qdeclarativestate.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/declarative/util/qdeclarativestate.cpp b/src/declarative/util/qdeclarativestate.cpp index 9f56ccb..ee3d06b 100644 --- a/src/declarative/util/qdeclarativestate.cpp +++ b/src/declarative/util/qdeclarativestate.cpp @@ -173,6 +173,18 @@ QDeclarativeState::~QDeclarativeState() Q_D(QDeclarativeState); if (d->group) d->group->removeState(this); + + /* + destroying an active state does not return us to the + base state, so we need to clean up our revert list to + prevent leaks. In the future we may want to redconsider + this overall architecture. + */ + for (int i = 0; i < d->revertList.count(); ++i) { + if (d->revertList.at(i).binding()) { + d->revertList.at(i).binding()->destroy(); + } + } } /*! -- cgit v0.12 From 95ba429db0652e8a8d2e1ef4eccdbde3925b195f Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Tue, 6 Sep 2011 10:28:38 +1000 Subject: Fix implicit height not growing when pre-edit text wraps. QTextDocument::isEmpty() doesn't account for pre-edit text so use the return value of size() to determine if implicitHeight should fall back to the font height instead. Change-Id: I028552a7646372b22894c45946a57ec4951b044a Task-number: QTBUG-21288 Reviewed-by: Martin Jones --- .../graphicsitems/qdeclarativetextedit.cpp | 4 +- .../tst_qdeclarativetextedit.cpp | 44 ++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index cc5279a..683807e 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -1713,7 +1713,9 @@ void QDeclarativeTextEdit::updateSize() setImplicitWidth(newWidth); else if (d->requireImplicitWidth) setImplicitWidth(naturalWidth); - qreal newHeight = d->document->isEmpty() ? fm.height() : (int)d->document->size().height(); + qreal newHeight = d->document->size().height(); + if (newHeight == 0) + newHeight = fm.height(); setImplicitHeight(newHeight); d->paintedSize = QSize(newWidth, newHeight); diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index fde0588..33f74a9 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -147,6 +147,8 @@ private slots: void pastingRichText_QTBUG_14003(); void implicitSize_data(); void implicitSize(); + void implicitSizePreedit_data(); + void implicitSizePreedit(); void testQtQuick11Attributes(); void testQtQuick11Attributes_data(); @@ -2368,6 +2370,48 @@ void tst_qdeclarativetextedit::implicitSize() QVERIFY(textObject->height() == textObject->implicitHeight()); } +void tst_qdeclarativetextedit::implicitSizePreedit_data() +{ + QTest::addColumn("text"); + QTest::addColumn("wrap"); + QTest::addColumn("wrapped"); + QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.NoWrap" << false; + QTest::newRow("plain_wrap") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.Wrap" << true; + +} + +void tst_qdeclarativetextedit::implicitSizePreedit() +{ + QFETCH(QString, text); + QFETCH(QString, wrap); + QFETCH(bool, wrapped); + + QString componentStr = "import QtQuick 1.1\nTextEdit { focus: true; width: 50; wrapMode: " + wrap + " }"; + QDeclarativeComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeTextEdit *textObject = qobject_cast(textComponent.create()); + + QGraphicsScene scene; + QGraphicsView view(&scene); + scene.addItem(textObject); + view.show(); + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); + + QInputMethodEvent event(text, QList()); + QCoreApplication::sendEvent(&view, &event); + + QVERIFY(textObject->width() < textObject->implicitWidth()); + QVERIFY(textObject->height() == textObject->implicitHeight()); + qreal wrappedHeight = textObject->height(); + + textObject->resetWidth(); + QVERIFY(textObject->width() == textObject->implicitWidth()); + QVERIFY(textObject->height() == textObject->implicitHeight()); + QCOMPARE(textObject->height() < wrappedHeight, wrapped); +} + void tst_qdeclarativetextedit::testQtQuick11Attributes() { QFETCH(QString, code); -- cgit v0.12 From 7253fe0cb58699d911f7f5b2dca28dd7182b1ef9 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 7 Sep 2011 10:44:01 +1000 Subject: Dragging in nested views no longer works as expected The detection of a replay event doesn't work if the release event is not handled due to a parent grabbing the mouse. Use the spontaneous() flag to determine if we are dealing with a replay event. Change-Id: I36e39e6ad8e426bd5f5f2a013aa236aac34ba5cc Task-number: QTBUG-21219 Reviewed-by: Michael Brasser --- src/declarative/graphicsitems/qdeclarativeflickable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index 0a98c01..81e07fd 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -1553,7 +1553,7 @@ bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event) d->handleMouseMoveEvent(&mouseEvent); break; case QEvent::GraphicsSceneMousePress: - if (d->pressed) // we are already pressed - this is a delayed replay + if (d->pressed && !event->spontaneous()) // we are already pressed - this is a delayed replay return false; d->handleMousePressEvent(&mouseEvent); -- cgit v0.12