summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews/qabstractitemview.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-03-24 18:03:37 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-03-24 18:04:33 (GMT)
commitd44a204988320c7c1a990536565fcb655d34db1e (patch)
treeb671a45be1346f4eded801163d428fa3a93ae5e6 /src/gui/itemviews/qabstractitemview.cpp
parent01140c6c47ab073ffd35f4534f2222dd38f29127 (diff)
downloadQt-d44a204988320c7c1a990536565fcb655d34db1e.zip
Qt-d44a204988320c7c1a990536565fcb655d34db1e.tar.gz
Qt-d44a204988320c7c1a990536565fcb655d34db1e.tar.bz2
Fix qcombobox:flaggedItems autotest failure.
QElapsedTimer doesn't initialise itself on construction, which means we were actually depending on uninitialised data. QTime does initialise itself to NullTime. This means the test didn't actually work if you ran it precisely at midnight... Reviewed-By: Trust Me
Diffstat (limited to 'src/gui/itemviews/qabstractitemview.cpp')
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index 32d7bca..97fd6e1 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -107,6 +107,7 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate()
delayedPendingLayout(true),
moveCursorUpdatedView(false)
{
+ keyboardInputTime.invalidate();
}
QAbstractItemViewPrivate::~QAbstractItemViewPrivate()
@@ -2842,17 +2843,16 @@ void QAbstractItemView::keyboardSearch(const QString &search)
QModelIndex start = currentIndex().isValid() ? currentIndex()
: d->model->index(0, 0, d->root);
- QElapsedTimer now;
- now.start();
bool skipRow = false;
- if (search.isEmpty()
- || (d->keyboardInputTime.msecsTo(now) > QApplication::keyboardInputInterval())) {
+ bool keyboardTimeWasValid = d->keyboardInputTime.isValid();
+ qint64 keyboardInputTimeElapsed = d->keyboardInputTime.restart();
+ if (search.isEmpty() || !keyboardTimeWasValid
+ || keyboardInputTimeElapsed > QApplication::keyboardInputInterval()) {
d->keyboardInput = search;
skipRow = currentIndex().isValid(); //if it is not valid we should really start at QModelIndex(0,0)
} else {
d->keyboardInput += search;
}
- d->keyboardInputTime = now;
// special case for searches with same key like 'aaaaa'
bool sameKey = false;