aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-08-13 00:41:58 +0200
committerLiang Qi <liang.qi@qt.io>2016-08-13 00:41:58 +0200
commitd54d28981c90d23d7fa0cfc5a9e3049e3e4df6b5 (patch)
tree0eb2f54f16b014f6eaa362095393d1bd058adb52 /src/quick
parent580f2872f09cf7ad83ec9ae5dca686683a3cac80 (diff)
parent6f15de1d2da9c83d7fca1d5c8243c0d69a1390ee (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: src/qml/compiler/qv4isel_moth.cpp src/qml/compiler/qv4ssa_p.h tests/benchmarks/qml/qqmlimage/qqmlimage.pro tests/benchmarks/qml/qqmlimage/tst_qqmlimage.cpp Change-Id: Iad11ce7fdf0c6d200fdebc16a94081bd8069a87a
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/items/qquickclipnode.cpp2
-rw-r--r--src/quick/items/qquickflickable.cpp8
-rw-r--r--src/quick/items/qquickpathview.cpp60
-rw-r--r--src/quick/items/qquicktext.cpp1
-rw-r--r--src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp3
5 files changed, 49 insertions, 25 deletions
diff --git a/src/quick/items/qquickclipnode.cpp b/src/quick/items/qquickclipnode.cpp
index 1114686a9a..56f8227c05 100644
--- a/src/quick/items/qquickclipnode.cpp
+++ b/src/quick/items/qquickclipnode.cpp
@@ -93,7 +93,7 @@ void QQuickDefaultClipNode::updateGeometry()
int segments = qMin(30, qCeil(radius)); // Number of segments per corner.
- g->allocate((segments + 1) * 2);
+ g->allocate((segments + 1) * 4);
QVector2D *vertices = (QVector2D *)g->vertexData();
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp
index f72923a0d5..03b2a8128c 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -1234,13 +1234,17 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event)
return;
qint64 currentTimestamp = computeCurrentTime(event);
- qreal elapsed = qreal(currentTimestamp - (lastPos.isNull() ? lastPressTime : lastPosTime)) / 1000.;
QVector2D deltas = QVector2D(event->localPos() - pressPos);
bool overThreshold = false;
QVector2D velocity = QGuiApplicationPrivate::mouseEventVelocity(event);
// TODO guarantee that events always have velocity so that it never needs to be computed here
- if (!(QGuiApplicationPrivate::mouseEventCaps(event) & QTouchDevice::Velocity))
+ if (!(QGuiApplicationPrivate::mouseEventCaps(event) & QTouchDevice::Velocity)) {
+ qint64 lastTimestamp = (lastPos.isNull() ? lastPressTime : lastPosTime);
+ if (currentTimestamp == lastTimestamp)
+ return; // events are too close together: velocity would be infinite
+ qreal elapsed = qreal(currentTimestamp - lastTimestamp) / 1000.;
velocity = QVector2D(event->localPos() - (lastPos.isNull() ? pressPos : lastPos)) / elapsed;
+ }
if (q->yflick())
overThreshold |= QQuickWindowPrivate::dragOverThreshold(deltas.y(), Qt::YAxis, event);
diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp
index c7e476c4b5..0c3f5a6974 100644
--- a/src/quick/items/qquickpathview.cpp
+++ b/src/quick/items/qquickpathview.cpp
@@ -296,6 +296,8 @@ qreal QQuickPathViewPrivate::positionOfIndex(qreal index) const
// account the circular space.
bool QQuickPathViewPrivate::isInBound(qreal position, qreal lower, qreal upper) const
{
+ if (lower == upper)
+ return true;
if (lower > upper) {
if (position > upper && position > lower)
position -= mappedRange;
@@ -1903,6 +1905,14 @@ void QQuickPathView::updatePolish()
refill();
}
+static inline int currentIndexRemainder(int currentIndex, int modelCount) Q_DECL_NOTHROW
+{
+ if (currentIndex < 0)
+ return modelCount + currentIndex % modelCount;
+ else
+ return currentIndex % modelCount;
+}
+
void QQuickPathView::componentComplete()
{
Q_D(QQuickPathView);
@@ -1914,7 +1924,7 @@ void QQuickPathView::componentComplete()
if (d->model) {
d->modelCount = d->model->count();
if (d->modelCount && d->currentIndex != 0) // an initial value has been provided for currentIndex
- d->offset = qmlMod(d->modelCount - d->currentIndex, d->modelCount);
+ d->offset = qmlMod(d->modelCount - currentIndexRemainder(d->currentIndex, d->modelCount), d->modelCount);
}
d->createHighlight();
@@ -1988,7 +1998,8 @@ void QQuickPathView::refill()
qreal endPos;
int startIdx = 0;
qreal startPos = 0.0;
- if (d->items.count()) {
+ const bool wasEmpty = d->items.isEmpty();
+ if (!wasEmpty) {
//Find the beginning and end, items may not be in sorted order
endPos = -1.0;
startPos = 2.0;
@@ -2047,7 +2058,8 @@ void QQuickPathView::refill()
}
//Prepend
- idx = startIdx - 1;
+ idx = (wasEmpty ? d->calcCurrentIndex() : startIdx) - 1;
+
if (idx < 0)
idx = d->modelCount - 1;
nextPos = d->positionOfIndex(idx);
@@ -2086,27 +2098,33 @@ void QQuickPathView::refill()
idx = startIdx;
QQuickItem *lastItem = d->items[0];
while (idx != endIdx) {
- //This gets the reference from the delegate model, and will not re-create
- QQuickItem *item = d->getItem(idx, idx+1, nextPos >= 1.0);
- if (!item) {
- waiting = true;
- break;
- }
- if (!d->items.contains(item)) { //We found a hole
- nextPos = d->positionOfIndex(idx);
- qCDebug(lcItemViewDelegateLifecycle) << "middle insert" << idx << "@" << nextPos << (d->currentIndex == idx ? "current" : "") << "items count was" << d->items.count();
- if (d->currentIndex == idx) {
- currentVisible = true;
- d->currentItemOffset = nextPos;
+ nextPos = d->positionOfIndex(idx);
+ if (d->isInBound(nextPos, d->mappedRange - d->mappedCache, 1.0 + d->mappedCache)) {
+ //This gets the reference from the delegate model, and will not re-create
+ QQuickItem *item = d->getItem(idx, idx+1, nextPos >= 1.0);
+ if (!item) {
+ waiting = true;
+ break;
}
- int lastListIdx = d->items.indexOf(lastItem);
- d->items.insert(lastListIdx + 1, item);
- d->updateItem(item, nextPos);
- } else {
- d->releaseItem(item);
+
+ if (!d->items.contains(item)) { //We found a hole
+ qCDebug(lcItemViewDelegateLifecycle) << "middle insert" << idx << "@" << nextPos
+ << (d->currentIndex == idx ? "current" : "")
+ << "items count was" << d->items.count();
+ if (d->currentIndex == idx) {
+ currentVisible = true;
+ d->currentItemOffset = nextPos;
+ }
+ int lastListIdx = d->items.indexOf(lastItem);
+ d->items.insert(lastListIdx + 1, item);
+ d->updateItem(item, nextPos);
+ } else {
+ d->releaseItem(item);
+ }
+
+ lastItem = item;
}
- lastItem = item;
++idx;
if (idx >= d->modelCount)
idx = 0;
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index 59331647e5..8288554028 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -2028,6 +2028,7 @@ void QQuickText::setTextFormat(TextFormat format)
}
d->updateLayout();
setAcceptHoverEvents(d->richText || d->styledText);
+ setAcceptedMouseButtons(d->richText || d->styledText ? Qt::LeftButton : Qt::NoButton);
emit textFormatChanged(d->format);
}
diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
index b28ca7725a..bb4a3b04d5 100644
--- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
+++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
@@ -259,7 +259,8 @@ void QSGDefaultDistanceFieldGlyphCache::createTexture(TextureInfo *texInfo, int
const GLenum format = GL_ALPHA;
#endif
- m_funcs->glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, 0);
+ QByteArray zeroBuf(width * height, 0);
+ m_funcs->glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, zeroBuf.constData());
texInfo->size = QSize(width, height);