diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-03-24 18:03:37 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-03-24 18:04:33 (GMT) |
commit | d44a204988320c7c1a990536565fcb655d34db1e (patch) | |
tree | b671a45be1346f4eded801163d428fa3a93ae5e6 /src/gui/itemviews | |
parent | 01140c6c47ab073ffd35f4534f2222dd38f29127 (diff) | |
download | Qt-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')
-rw-r--r-- | src/gui/itemviews/qabstractitemview.cpp | 10 | ||||
-rw-r--r-- | src/gui/itemviews/qtreeview.cpp | 11 |
2 files changed, 10 insertions, 11 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; diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 063f3f4..d934683 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -962,17 +962,16 @@ void QTreeView::keyboardSearch(const QString &search) else start = 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 = true; + 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; |