summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-12-03 06:06:46 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-12-03 06:06:46 (GMT)
commit2b07e188b91d2cb92a2c41f85678415c4dbb3721 (patch)
tree445c524bf3a587a0c676b7895df76772eaaaf1bc /src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
parent00e793e43c51f2b8b8ac230812822155aef8362b (diff)
downloadQt-2b07e188b91d2cb92a2c41f85678415c4dbb3721.zip
Qt-2b07e188b91d2cb92a2c41f85678415c4dbb3721.tar.gz
Qt-2b07e188b91d2cb92a2c41f85678415c4dbb3721.tar.bz2
A collection of small optimizations.
Diffstat (limited to 'src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp')
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
index 6c594cf..2aa9397 100644
--- a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
@@ -119,6 +119,12 @@ void QmlGraphicsDrag::setYmax(qreal m)
_ymax = m;
}
+QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate()
+{
+ delete drag;
+}
+
+
/*!
\qmlclass MouseRegion QmlGraphicsMouseRegion
\brief The MouseRegion item enables simple mouse handling.
@@ -339,8 +345,10 @@ void QmlGraphicsMouseRegion::mousePressEvent(QGraphicsSceneMouseEvent *event)
else {
d->longPress = false;
d->saveEvent(event);
- d->dragX = drag()->axis() & QmlGraphicsDrag::XAxis;
- d->dragY = drag()->axis() & QmlGraphicsDrag::YAxis;
+ if (d->drag) {
+ d->dragX = drag()->axis() & QmlGraphicsDrag::XAxis;
+ d->dragY = drag()->axis() & QmlGraphicsDrag::YAxis;
+ }
d->dragged = false;
setHovered(true);
d->start = event->pos();
@@ -371,7 +379,7 @@ void QmlGraphicsMouseRegion::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
else if (!d->hovered && contains)
setHovered(true);
- if (drag()->target()) {
+ if (d->drag && d->drag->target()) {
if (!d->moved) {
if (d->dragX) d->startX = drag()->target()->x();
if (d->dragY) d->startY = drag()->target()->y();
@@ -616,7 +624,9 @@ bool QmlGraphicsMouseRegion::setPressed(bool p)
QmlGraphicsDrag *QmlGraphicsMouseRegion::drag()
{
Q_D(QmlGraphicsMouseRegion);
- return &(d->drag);
+ if (!d->drag)
+ d->drag = new QmlGraphicsDrag;
+ return d->drag;
}
/*!