detach() safely in QVector::erase(), and update callers to not detach.
authorAndreas Hartmetz <andreas.hartmetz@kdab.com>
Sun, 14 Oct 2012 02:28:51 +0000 (04:28 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Fri, 19 Oct 2012 16:04:11 +0000 (18:04 +0200)
commitbdc115d9698d4f3cf5ce089dbddca75e425d3eeb
tree07951c7374ebf7f7c82959872be0d00103e353a0
parentc4ff5c53efc213d9ce4fe0cfe9ab3d6c13cd8716
detach() safely in QVector::erase(), and update callers to not detach.

remove() can use non-detaching iterators internally before calling
erase(), which hasn't been exploited so far, so that the detach() in
erase() never actually detached. When using erase() from outside,
you can't do it legally without calling begin() or end() that detach()
before erase() is called.
Now remove() doesn't detach anymore, and detaching in erase() works.
With new tests that fail after changing only the erase() callers
and pass again after fixing erase().

Change-Id: I47c0a9e362dce8628ec566f5437d951755de96c8
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
src/corelib/tools/qvector.h
tests/auto/corelib/tools/qvector/tst_qvector.cpp