From fe23e4f9aeb782c6278ef5b6ff9375182325a7f1 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 26 Oct 2009 11:19:39 +1000 Subject: Avoid unnecessary trademark. --- examples/declarative/follow/pong.qml | 74 -------------------------------- examples/declarative/follow/tvtennis.qml | 74 ++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 74 deletions(-) delete mode 100644 examples/declarative/follow/pong.qml create mode 100644 examples/declarative/follow/tvtennis.qml diff --git a/examples/declarative/follow/pong.qml b/examples/declarative/follow/pong.qml deleted file mode 100644 index d39e913..0000000 --- a/examples/declarative/follow/pong.qml +++ /dev/null @@ -1,74 +0,0 @@ -import Qt 4.6 - -Rectangle { - id: page - width: 640; height: 480 - color: "Black" - - // Make a ball to bounce - Rectangle { - // Add a property for the target y coordinate - property var targetY : page.height - 10 - property var direction : "right" - - id: ball - color: "Lime" - x: 20; width: 20; height: 20; z: 1 - - // Move the ball to the right and back to the left repeatedly - x: SequentialAnimation { - running: true; repeat: true - NumberAnimation { to: page.width - 40; duration: 2000 } - ScriptAction { script: Qt.playSound('paddle.wav') } - PropertyAction { target: ball; property: "direction"; value: "left" } - NumberAnimation { to: 20; duration: 2000 } - ScriptAction { script: Qt.playSound('paddle.wav') } - PropertyAction { target: ball; property: "direction"; value: "right" } - } - - // Make y follow the target y coordinate, with a velocity of 200 - y: SpringFollow { source: ball.targetY; velocity: 200 } - - // Detect the ball hitting the top or bottom of the view and bounce it - onYChanged: { - if (y <= 0) { - Qt.playSound('click.wav'); - targetY = page.height - 20; - } else if (y >= page.height - 20) { - Qt.playSound('click.wav'); - targetY = 0; - } - } - } - - // Place bats to the left and right of the view, following the y - // coordinates of the ball. - Rectangle { - id: leftBat - color: "Lime" - x: 2; width: 20; height: 90 - y: SpringFollow { - source: ball.y - 45; velocity: 300 - enabled: ball.direction == 'left' - } - } - Rectangle { - id: rightBat - color: "Lime" - x: page.width - 22; width: 20; height: 90 - y: SpringFollow { - source: ball.y-45; velocity: 300 - enabled: ball.direction == 'right' - } - } - - // The rest, to make it look realistic, if neither ever scores... - Rectangle { color: "Lime"; x: page.width/2-80; y: 0; width: 40; height: 60 } - Rectangle { color: "Black"; x: page.width/2-70; y: 10; width: 20; height: 40 } - Rectangle { color: "Lime"; x: page.width/2+40; y: 0; width: 40; height: 60 } - Rectangle { color: "Black"; x: page.width/2+50; y: 10; width: 20; height: 40 } - Repeater { - model: page.height / 20 - Rectangle { color: "Lime"; x: page.width/2-5; y: index * 20; width: 10; height: 10 } - } -} diff --git a/examples/declarative/follow/tvtennis.qml b/examples/declarative/follow/tvtennis.qml new file mode 100644 index 0000000..d39e913 --- /dev/null +++ b/examples/declarative/follow/tvtennis.qml @@ -0,0 +1,74 @@ +import Qt 4.6 + +Rectangle { + id: page + width: 640; height: 480 + color: "Black" + + // Make a ball to bounce + Rectangle { + // Add a property for the target y coordinate + property var targetY : page.height - 10 + property var direction : "right" + + id: ball + color: "Lime" + x: 20; width: 20; height: 20; z: 1 + + // Move the ball to the right and back to the left repeatedly + x: SequentialAnimation { + running: true; repeat: true + NumberAnimation { to: page.width - 40; duration: 2000 } + ScriptAction { script: Qt.playSound('paddle.wav') } + PropertyAction { target: ball; property: "direction"; value: "left" } + NumberAnimation { to: 20; duration: 2000 } + ScriptAction { script: Qt.playSound('paddle.wav') } + PropertyAction { target: ball; property: "direction"; value: "right" } + } + + // Make y follow the target y coordinate, with a velocity of 200 + y: SpringFollow { source: ball.targetY; velocity: 200 } + + // Detect the ball hitting the top or bottom of the view and bounce it + onYChanged: { + if (y <= 0) { + Qt.playSound('click.wav'); + targetY = page.height - 20; + } else if (y >= page.height - 20) { + Qt.playSound('click.wav'); + targetY = 0; + } + } + } + + // Place bats to the left and right of the view, following the y + // coordinates of the ball. + Rectangle { + id: leftBat + color: "Lime" + x: 2; width: 20; height: 90 + y: SpringFollow { + source: ball.y - 45; velocity: 300 + enabled: ball.direction == 'left' + } + } + Rectangle { + id: rightBat + color: "Lime" + x: page.width - 22; width: 20; height: 90 + y: SpringFollow { + source: ball.y-45; velocity: 300 + enabled: ball.direction == 'right' + } + } + + // The rest, to make it look realistic, if neither ever scores... + Rectangle { color: "Lime"; x: page.width/2-80; y: 0; width: 40; height: 60 } + Rectangle { color: "Black"; x: page.width/2-70; y: 10; width: 20; height: 40 } + Rectangle { color: "Lime"; x: page.width/2+40; y: 0; width: 40; height: 60 } + Rectangle { color: "Black"; x: page.width/2+50; y: 10; width: 20; height: 40 } + Repeater { + model: page.height / 20 + Rectangle { color: "Lime"; x: page.width/2-5; y: index * 20; width: 10; height: 10 } + } +} -- cgit v0.12 From 5d7f9e852a1de2c949ad6ca866d11a33b4152d29 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 26 Oct 2009 11:24:40 +1000 Subject: Fix assert with non-integer Rectangle radius. --- src/declarative/fx/qfxrect.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp index f35fe3d..d4207a6 100644 --- a/src/declarative/fx/qfxrect.cpp +++ b/src/declarative/fx/qfxrect.cpp @@ -43,6 +43,7 @@ #include "qfxrect_p.h" #include +#include QT_BEGIN_NAMESPACE QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Pen,QFxPen) @@ -338,7 +339,8 @@ void QFxRect::generateRoundedRect() Q_D(QFxRect); if (d->rectImage.isNull()) { const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0; - d->rectImage = QPixmap(d->radius*2 + 3 + pw*2, d->radius*2 + 3 + pw*2); + const int radius = qCeil(d->radius); //ensure odd numbered width/height so we get 1-pixel center + d->rectImage = QPixmap(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2); d->rectImage.fill(Qt::transparent); QPainter p(&(d->rectImage)); p.setRenderHint(QPainter::Antialiasing); @@ -361,7 +363,7 @@ void QFxRect::generateBorderedRect() Q_D(QFxRect); if (d->rectImage.isNull()) { const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0; - d->rectImage = QPixmap(d->getPen()->width()*2 + 3 + pw*2, d->getPen()->width()*2 + 3 + pw*2); + d->rectImage = QPixmap(pw*2 + 3, pw*2 + 3); d->rectImage.fill(Qt::transparent); QPainter p(&(d->rectImage)); p.setRenderHint(QPainter::Antialiasing); @@ -439,6 +441,7 @@ void QFxRect::drawRect(QPainter &p) QMargins margins(xOffset, yOffset, xOffset, yOffset); QTileRules rules(Qt::StretchTile, Qt::StretchTile); + //NOTE: even though our item may have qreal-based width and height, qDrawBorderPixmap only supports QRects qDrawBorderPixmap(&p, QRect(-pw/2, -pw/2, width()+pw, height()+pw), margins, d->rectImage, d->rectImage.rect(), margins, rules); if (d->smooth) { -- cgit v0.12 From 4fbd2ad6c90fa4946595c715dedf712d77350fb8 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 26 Oct 2009 11:25:17 +1000 Subject: Doc. --- doc/src/declarative/pics/3d-rotation-axis.png | Bin 14304 -> 11078 bytes doc/src/declarative/pics/axisrotation.png | Bin 3425 -> 8891 bytes doc/src/snippets/declarative/rotation.qml | 16 ++++++----- src/declarative/fx/qfxitem.cpp | 37 +++++++++++++++----------- 4 files changed, 31 insertions(+), 22 deletions(-) diff --git a/doc/src/declarative/pics/3d-rotation-axis.png b/doc/src/declarative/pics/3d-rotation-axis.png index 1b17261..b940215 100644 Binary files a/doc/src/declarative/pics/3d-rotation-axis.png and b/doc/src/declarative/pics/3d-rotation-axis.png differ diff --git a/doc/src/declarative/pics/axisrotation.png b/doc/src/declarative/pics/axisrotation.png index 409a9e9..4cddcdf 100644 Binary files a/doc/src/declarative/pics/axisrotation.png and b/doc/src/declarative/pics/axisrotation.png differ diff --git a/doc/src/snippets/declarative/rotation.qml b/doc/src/snippets/declarative/rotation.qml index aaaebee..4a67dcb 100644 --- a/doc/src/snippets/declarative/rotation.qml +++ b/doc/src/snippets/declarative/rotation.qml @@ -4,25 +4,29 @@ Rectangle { width: 360; height: 80 color: "white" //! [0] - HorizontalLayout { - margin: 10 + Row { + x: 10; y: 10 spacing: 10 Image { source: "pics/qt.png" } Image { source: "pics/qt.png" - transform: Rotation { origin.x: 30; axis.y: 60; axis.z: 0 angle: 18 } + transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 18 } + smooth: true } Image { source: "pics/qt.png" - transform: Rotation { origin.x: 30; axis.y: 60; axis.z: 0 angle: 36 } + transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 36 } + smooth: true } Image { source: "pics/qt.png" - transform: Rotation { origin.x: 30; axis.y: 60; axis.z: 0; angle: 54 } + transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 54 } + smooth: true } Image { source: "pics/qt.png" - transform: Rotation { origin.x: 30; axis.y: 60; axis.z: 0; angle: 72 } + transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 72 } + smooth: true } } //! [0] diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 317a284..b82a38d 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -79,15 +79,10 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QGraphicsRotation) #include "qfxeffects.cpp" /*! - \qmlclass Transform - \brief A transformation. -*/ - -/*! \qmlclass Scale - \brief A Scale object provides a way to scale an Item. + \brief The Scale object provides a way to scale an Item. - The scale object gives more control over scaling than using Item's scale property. Specifically, + The Scale object gives more control over scaling than using Item's scale property. Specifically, it allows a different scale for the x and y axes, and allows the scale to be relative to an arbitrary point. @@ -105,13 +100,14 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QGraphicsRotation) \qmlproperty real Scale::origin.x \qmlproperty real Scale::origin.y - The origin point for the scale. The scale will be relative to this point. + The point that the item is scaled from (i.e., the point that stays fixed relative to the parent as + the rest of the item grows). By default the origin is 0, 0. */ /*! \qmlproperty real Scale::xScale - The scaling factor for the X axis. + The scaling factor for the X axis. */ /*! @@ -122,7 +118,10 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QGraphicsRotation) /*! \qmlclass Rotation - \brief A Rotation object provides a way to rotate an Item around a point using an axis in 3D space. + \brief The Rotation object provides a way to rotate an Item. + + The Rotation object gives more control over rotation than using Item's rotation property. + Specifically, it allows (z axis) rotation to be relative to an arbitrary point. The following example rotates a Rectangle around its interior point 25, 25: \qml @@ -133,7 +132,10 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QGraphicsRotation) } \endqml - Here is an example of various rotations applied to an \l Image. + Rotation also provides a way to specify 3D-like rotations for Items. For these types of + rotations you must specify the axis to rotate around in addition to the origin point. + + The following example shows various 3D-like rotations applied to an \l Image. \snippet doc/src/snippets/declarative/rotation.qml 0 \image axisrotation.png @@ -143,7 +145,8 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QGraphicsRotation) \qmlproperty real Rotation::origin.x \qmlproperty real Rotation::origin.y - The point to rotate around. + The origin point of the rotation (i.e., the point that stays fixed relative to the parent as + the rest of the item rotates). By default the origin is 0, 0. */ /*! @@ -151,16 +154,18 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QGraphicsRotation) \qmlproperty real Rotation::axis.y \qmlproperty real Rotation::axis.z - A rotation axis is specified by a vector in 3D space By default the vector defines a rotation around the z-Axis. + The axis to rotate around. For simple (2D) rotation around a point, you do not need to specify an axis, + as the default axis is the z axis (\c{ axis { x: 0; y: 0; z: 0 } }). - \image 3d-rotation-axis.png + For a typical 3D-like rotation you will usually specify both the origin and the axis. + \image 3d-rotation-axis.png */ /*! \qmlproperty real Rotation::angle - The angle, in degrees, to rotate. + The angle to rotate, in degrees clockwise. */ @@ -2113,7 +2118,7 @@ void QFxItem::setBaselineOffset(qreal offset) /*! \qmlproperty real Item::rotation - This property holds the rotation of the item in degrees. + This property holds the rotation of the item in degrees clockwise. This specifies how many degrees to rotate the item around its transformOrigin. The default rotation is 0 degrees (i.e. not rotated at all). -- cgit v0.12 From 2b0cf3b6a2f1c49f40d6f50b4d24bdd87a4807fa Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 26 Oct 2009 11:36:00 +1000 Subject: Ensure cleanup happens before the destruction of QScriptEngine This was causing crashes on windows. --- src/declarative/qml/qml.pri | 2 + src/declarative/qml/qmlcleanup.cpp | 82 ++++++++++++++++++++++++++++++++ src/declarative/qml/qmlcleanup_p.h | 79 ++++++++++++++++++++++++++++++ src/declarative/qml/qmlengine.cpp | 11 ++++- src/declarative/qml/qmlengine_p.h | 4 ++ src/declarative/qml/qmlintegercache.cpp | 10 +++- src/declarative/qml/qmlintegercache_p.h | 7 ++- src/declarative/qml/qmlpropertycache.cpp | 14 +++++- src/declarative/qml/qmlpropertycache_p.h | 8 +++- src/declarative/qml/qmltypenamecache.cpp | 10 +++- src/declarative/qml/qmltypenamecache_p.h | 6 ++- 11 files changed, 224 insertions(+), 9 deletions(-) create mode 100644 src/declarative/qml/qmlcleanup.cpp create mode 100644 src/declarative/qml/qmlcleanup_p.h diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index b6e86a8..cbc2f85 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -37,6 +37,7 @@ SOURCES += qml/qmlparser.cpp \ qml/qmetaobjectbuilder.cpp \ qml/qmlwatcher.cpp \ qml/qmlscript.cpp \ + qml/qmlcleanup.cpp \ qml/qmlpropertycache.cpp \ qml/qmlintegercache.cpp \ qml/qmltypenamecache.cpp \ @@ -100,6 +101,7 @@ HEADERS += qml/qmlparser_p.h \ qml/qmlsqldatabase_p.h \ qml/qmetaobjectbuilder_p.h \ qml/qmlwatcher_p.h \ + qml/qmlcleanup_p.h \ qml/qmlpropertycache_p.h \ qml/qmlintegercache_p.h \ qml/qmltypenamecache_p.h \ diff --git a/src/declarative/qml/qmlcleanup.cpp b/src/declarative/qml/qmlcleanup.cpp new file mode 100644 index 0000000..7799cfc --- /dev/null +++ b/src/declarative/qml/qmlcleanup.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmlcleanup_p.h" +#include + +/*! +\internal +\class QmlCleanup +\brief The QmlCleanup provides a callback when a QmlEngine is deleted. + +Any object that needs cleanup to occur before the QmlEngine's QScriptEngine is +destroyed should inherit from QmlCleanup. The clear() virtual method will be +called by QmlEngine just before it deletes the QScriptEngine. +*/ + +/*! +\internal + +Create a QmlCleanup for \a engine +*/ +QmlCleanup::QmlCleanup(QmlEngine *engine) +: prev(0), next(0) +{ + Q_ASSERT(engine); + QmlEnginePrivate *p = QmlEnginePrivate::get(engine); + + if (p->cleanup) next = p->cleanup; + p->cleanup = this; + prev = &p->cleanup; + if (next) next->prev = &next; +} + +/*! +\internal +*/ +QmlCleanup::~QmlCleanup() +{ + if (prev) *prev = next; + if (next) next->prev = prev; + prev = 0; + next = 0; +} + diff --git a/src/declarative/qml/qmlcleanup_p.h b/src/declarative/qml/qmlcleanup_p.h new file mode 100644 index 0000000..e9196a3 --- /dev/null +++ b/src/declarative/qml/qmlcleanup_p.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLCLEANUP_P_H +#define QMLCLEANUP_P_H + +#include + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QmlEngine; +class QmlCleanup +{ +public: + QmlCleanup(QmlEngine *); + virtual ~QmlCleanup(); + +protected: + virtual void clear() = 0; + +private: + friend class QmlEnginePrivate; + QmlCleanup **prev; + QmlCleanup *next; +}; + +QT_END_NAMESPACE + +#endif // QMLCLEANUP_P_H + diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 354114a..4f3b2ba 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -128,7 +128,7 @@ static QString userLocalDataPath(const QString& app) QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) : rootContext(0), currentExpression(0), isDebugging(false), contextClass(0), objectClass(0), valueTypeClass(0), globalClass(0), - nodeListClass(0), namedNodeMapClass(0), sqlQueryClass(0), scriptEngine(this), + nodeListClass(0), namedNodeMapClass(0), sqlQueryClass(0), cleanup(0), scriptEngine(this), componentAttacheds(0), rootComponent(0), networkAccessManager(0), typeManager(e), uniqueId(1) { QScriptValue qtObject = @@ -168,6 +168,15 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) QmlEnginePrivate::~QmlEnginePrivate() { + while (cleanup) { + QmlCleanup *c = cleanup; + cleanup = c->next; + if (cleanup) cleanup->prev = &cleanup; + c->next = 0; + c->prev = 0; + c->clear(); + } + delete rootContext; rootContext = 0; delete contextClass; diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index a74854d..29621c0 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -97,6 +97,7 @@ class QmlTypeNameScriptClass; class QmlTypeNameCache; class QmlComponentAttached; class QmlListScriptClass; +class QmlCleanup; class QmlEnginePrivate : public QObjectPrivate { @@ -139,6 +140,9 @@ public: // Used by SQL database API QScriptClass *sqlQueryClass; + // Registered cleanup handlers + QmlCleanup *cleanup; + struct QmlScriptEngine : public QScriptEngine { QmlScriptEngine(QmlEnginePrivate *priv) diff --git a/src/declarative/qml/qmlintegercache.cpp b/src/declarative/qml/qmlintegercache.cpp index 89a18a1..06955c7 100644 --- a/src/declarative/qml/qmlintegercache.cpp +++ b/src/declarative/qml/qmlintegercache.cpp @@ -46,13 +46,21 @@ QT_BEGIN_NAMESPACE QmlIntegerCache::QmlIntegerCache(QmlEngine *e) -: engine(e) +: QmlCleanup(e), engine(e) { } QmlIntegerCache::~QmlIntegerCache() { + clear(); +} + +void QmlIntegerCache::clear() +{ qDeleteAll(stringCache); + stringCache.clear(); + identifierCache.clear(); + engine = 0; } void QmlIntegerCache::add(const QString &id, int value) diff --git a/src/declarative/qml/qmlintegercache_p.h b/src/declarative/qml/qmlintegercache_p.h index e11e0be..6e9fadd 100644 --- a/src/declarative/qml/qmlintegercache_p.h +++ b/src/declarative/qml/qmlintegercache_p.h @@ -55,13 +55,14 @@ #include #include +#include #include QT_BEGIN_NAMESPACE class QmlType; class QmlEngine; -class QmlIntegerCache : public QmlRefCount +class QmlIntegerCache : public QmlRefCount, public QmlCleanup { public: QmlIntegerCache(QmlEngine *); @@ -73,6 +74,10 @@ public: inline int value(const QScriptDeclarativeClass::Identifier &id) const; static QmlIntegerCache *createForEnums(QmlType *, QmlEngine *); + +protected: + virtual void clear(); + private: struct Data : public QScriptDeclarativeClass::PersistentIdentifier { Data(const QScriptDeclarativeClass::PersistentIdentifier &i, int v) diff --git a/src/declarative/qml/qmlpropertycache.cpp b/src/declarative/qml/qmlpropertycache.cpp index e00126f..3ede341 100644 --- a/src/declarative/qml/qmlpropertycache.cpp +++ b/src/declarative/qml/qmlpropertycache.cpp @@ -86,12 +86,18 @@ void QmlPropertyCache::Data::load(const QMetaMethod &m) } -QmlPropertyCache::QmlPropertyCache() +QmlPropertyCache::QmlPropertyCache(QmlEngine *engine) +: QmlCleanup(engine) { } QmlPropertyCache::~QmlPropertyCache() { + clear(); +} + +void QmlPropertyCache::clear() +{ for (int ii = 0; ii < indexCache.count(); ++ii) indexCache.at(ii)->release(); @@ -102,6 +108,10 @@ QmlPropertyCache::~QmlPropertyCache() for (IdentifierCache::ConstIterator iter = identifierCache.begin(); iter != identifierCache.end(); ++iter) (*iter)->release(); + + indexCache.clear(); + stringCache.clear(); + identifierCache.clear(); } QmlPropertyCache::Data QmlPropertyCache::create(const QMetaObject *metaObject, @@ -141,7 +151,7 @@ QmlPropertyCache *QmlPropertyCache::create(QmlEngine *engine, const QMetaObject Q_ASSERT(engine); Q_ASSERT(metaObject); - QmlPropertyCache *cache = new QmlPropertyCache; + QmlPropertyCache *cache = new QmlPropertyCache(engine); QmlEnginePrivate *enginePriv = QmlEnginePrivate::get(engine); diff --git a/src/declarative/qml/qmlpropertycache_p.h b/src/declarative/qml/qmlpropertycache_p.h index 91b0c53..6c3142a 100644 --- a/src/declarative/qml/qmlpropertycache_p.h +++ b/src/declarative/qml/qmlpropertycache_p.h @@ -55,16 +55,17 @@ #include #include +#include #include QT_BEGIN_NAMESPACE class QmlEngine; class QMetaProperty; -class QmlPropertyCache : public QmlRefCount +class QmlPropertyCache : public QmlRefCount, public QmlCleanup { public: - QmlPropertyCache(); + QmlPropertyCache(QmlEngine *); virtual ~QmlPropertyCache(); struct Data { @@ -112,6 +113,9 @@ public: Data *property(const QString &) const; Data *property(int) const; +protected: + virtual void clear(); + private: struct RData : public Data, public QmlRefCount { QScriptDeclarativeClass::PersistentIdentifier identifier; diff --git a/src/declarative/qml/qmltypenamecache.cpp b/src/declarative/qml/qmltypenamecache.cpp index aa1c938..d706c63 100644 --- a/src/declarative/qml/qmltypenamecache.cpp +++ b/src/declarative/qml/qmltypenamecache.cpp @@ -45,13 +45,21 @@ QT_BEGIN_NAMESPACE QmlTypeNameCache::QmlTypeNameCache(QmlEngine *e) -: engine(e) +: QmlCleanup(e), engine(e) { } QmlTypeNameCache::~QmlTypeNameCache() { + clear(); +} + +void QmlTypeNameCache::clear() +{ qDeleteAll(stringCache); + stringCache.clear(); + identifierCache.clear(); + engine = 0; } void QmlTypeNameCache::add(const QString &name, QmlType *type) diff --git a/src/declarative/qml/qmltypenamecache_p.h b/src/declarative/qml/qmltypenamecache_p.h index f11fe68..ec1e79d 100644 --- a/src/declarative/qml/qmltypenamecache_p.h +++ b/src/declarative/qml/qmltypenamecache_p.h @@ -55,12 +55,13 @@ #include #include +#include QT_BEGIN_NAMESPACE class QmlType; class QmlEngine; -class QmlTypeNameCache : public QmlRefCount +class QmlTypeNameCache : public QmlRefCount, public QmlCleanup { public: QmlTypeNameCache(QmlEngine *); @@ -79,6 +80,9 @@ public: Data *data(const QString &) const; inline Data *data(const QScriptDeclarativeClass::Identifier &id) const; +protected: + virtual void clear(); + private: struct RData : public Data { QScriptDeclarativeClass::PersistentIdentifier identifier; -- cgit v0.12 From 05d3e827565d635e75cfd49e46b3ba72903a1e6f Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 26 Oct 2009 11:39:41 +1000 Subject: Flip around perspective origin --- demos/declarative/flickr/common/ImageDetails.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/declarative/flickr/common/ImageDetails.qml b/demos/declarative/flickr/common/ImageDetails.qml index b8b7d29..cc00773 100644 --- a/demos/declarative/flickr/common/ImageDetails.qml +++ b/demos/declarative/flickr/common/ImageDetails.qml @@ -20,6 +20,7 @@ Flipable { transform: Rotation { id: detailsRotation + origin.y: container.height / 2; origin.x: container.width / 2; axis.y: 1; axis.z: 0 } -- cgit v0.12 From 24498457049f0504d0b09935dea6ca6a5634bb2d Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 26 Oct 2009 11:57:45 +1000 Subject: Fix crash. --- src/declarative/util/qmlpropertychanges.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/declarative/util/qmlpropertychanges.cpp b/src/declarative/util/qmlpropertychanges.cpp index a112245..bed27fe 100644 --- a/src/declarative/util/qmlpropertychanges.cpp +++ b/src/declarative/util/qmlpropertychanges.cpp @@ -85,7 +85,8 @@ class QmlReplaceSignalHandler : public ActionEvent public: QmlReplaceSignalHandler() : expression(0), reverseExpression(0), ownedExpression(0) {} ~QmlReplaceSignalHandler() { - delete ownedExpression; + if (ownedExpression) + delete ownedExpression; } virtual QString typeName() const { return QLatin1String("ReplaceSignalHandler"); } @@ -93,7 +94,7 @@ public: QmlMetaProperty property; QmlExpression *expression; QmlExpression *reverseExpression; - QmlExpression *ownedExpression; + QGuard ownedExpression; virtual void execute() { ownedExpression = property.setSignalExpression(expression); @@ -272,7 +273,6 @@ QmlPropertyChanges::~QmlPropertyChanges() delete d->expressions.at(ii).second; for(int ii = 0; ii < d->signalReplacements.count(); ++ii) delete d->signalReplacements.at(ii); - } QObject *QmlPropertyChanges::object() const -- cgit v0.12 From 60b8fc37ac04b9247481e5f03d1d7fa9ae059a07 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 26 Oct 2009 12:35:48 +1000 Subject: Doc. --- src/declarative/fx/qfxitem.cpp | 13 +++++++++++++ src/declarative/fx/qfxpainteditem.cpp | 2 +- src/declarative/qml/qmlmetaproperty.cpp | 1 + src/declarative/qml/qmlpropertyvalueinterceptor.cpp | 1 + src/declarative/qml/qmlpropertyvaluesource.cpp | 1 + 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index b82a38d..51575cc 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1198,6 +1198,19 @@ QFxKeysAttached *QFxKeysAttached::qmlAttachedProperties(QObject *obj) } /*! + \class QFxItem + \brief QFxItem is the most basic of all visual items in QML. + + All visual items in Qt Declarative inherit from QFxItem. Although QFxItem + has no visual appearance, it defines all the properties that are + common across visual items - such as the x and y position, the + width and height, \l {anchor-layout}{anchoring} and key handling. + + You can subclass QFxItem to provide your own custom visual item that inherits + these features. +*/ + +/*! \qmlclass Item QFxItem \brief The Item is the most basic of all visual items in QML. diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp index 05fcc93..e0ef99f 100644 --- a/src/declarative/fx/qfxpainteditem.cpp +++ b/src/declarative/fx/qfxpainteditem.cpp @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE /*! \class QFxPaintedItem \brief The QFxPaintedItem class is an abstract base class for QmlView items that want cached painting. - \ingroup group_coreitems + \internal This is a convenience class for implementing items that paint their contents using a QPainter. The contents of the item are cached behind the scenes. diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index baef71f..edec988 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -61,6 +61,7 @@ QT_BEGIN_NAMESPACE /*! \class QmlMetaProperty \brief The QmlMetaProperty class abstracts accessing QML properties. + \internal */ /*! diff --git a/src/declarative/qml/qmlpropertyvalueinterceptor.cpp b/src/declarative/qml/qmlpropertyvalueinterceptor.cpp index 86905e6..9a9aba8 100644 --- a/src/declarative/qml/qmlpropertyvalueinterceptor.cpp +++ b/src/declarative/qml/qmlpropertyvalueinterceptor.cpp @@ -47,6 +47,7 @@ QT_BEGIN_NAMESPACE /*! \class QmlPropertyValueInterceptor \brief The QmlPropertyValueInterceptor class is inherited by property interceptors such as Behavior. + \internal This class intercepts property writes, allowing for custom handling. For example, Behavior uses this interception to provide a default animation for all changes to a property's value. diff --git a/src/declarative/qml/qmlpropertyvaluesource.cpp b/src/declarative/qml/qmlpropertyvaluesource.cpp index 529ce37..3317289 100644 --- a/src/declarative/qml/qmlpropertyvaluesource.cpp +++ b/src/declarative/qml/qmlpropertyvaluesource.cpp @@ -47,6 +47,7 @@ QT_BEGIN_NAMESPACE /*! \class QmlPropertyValueSource \brief The QmlPropertyValueSource class is inherited by property value sources such as animations and bindings. + \internal */ /*! -- cgit v0.12