qt5base-lts/tests/auto/corelib/tools
João Abecasis 9a890a519e Add support for setSharable in RefCount
A reference count of 0 (zero) would never change. RefCount::deref to
zero would return false (resource should be freed), subsequent calls on
the same state would return true and not change state. While safe from
RefCount's side, calling deref on a reference count of zero potentially
indicated a dangling reference.

With this change, a reference count of 0 is now abused to imply a
non-sharable instance (cf. QVector::setSharable). This instance is to be
deleted upon deref(), as the data is not shared and has a single owner.

In practice, this means an (intentional) change in behaviour in that
deref'ing zero still won't change state, but will return false, turning
previous access to dangling references into double free errors.

Users of RefCount wanting to support non-sharable instances are required
to check the return of RefCount::ref() and use RefCount::isShared() to
determine whether to detach (instead of directly checking count == 1).

New functions are introduced to determine whether RefCount indicates a
"Static" (permanent, typically read-only) or "Sharable" instance and
whether the instance is currently "Shared" and requires detaching prior
to accepting modifications..

This change formalizes -1 as the value used to flag persistent,
read-only instances, no longer reserving the full negative domain. The
concrete value is part of the ABI, but not of the API. (isStatic and
Q_REFCOUNT_INITIALIZE_STATIC are part of the API, instead)

Change-Id: I9a63c844155319bef0411e02b47f9d92476afefe
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2012-01-05 13:59:14 +01:00
..
qalgorithms Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qarraydata Add support for setSharable in RefCount 2012-01-05 13:59:14 +01:00
qbitarray Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qbytearray Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qbytearraymatcher Cleanup corelib autotests 2011-11-29 05:16:52 +01:00
qcache Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qchar Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qcontiguouscache Cleanup corelib autotests 2011-11-11 02:45:05 +01:00
qcryptographichash Cleanup corelib autotests 2011-11-11 02:45:05 +01:00
qdate Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qdatetime Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qeasingcurve Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qelapsedtimer Fixed installation of corelib tests 2011-12-01 09:12:52 +01:00
qexplicitlyshareddatapointer Cleanup corelib autotests 2011-11-11 02:45:05 +01:00
qfreelist Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qhash Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qline Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qlist Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qlocale Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qmap Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qmargins Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qpoint Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qqueue Cleanup corelib autotests 2011-11-11 02:45:05 +01:00
qrect Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qregexp Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qringbuffer Cleanup corelib autotests 2011-11-11 02:45:05 +01:00
qscopedpointer Remove warnings from deprecated atomic operators in autotests 2011-11-16 10:32:10 +01:00
qscopedvaluerollback Cleanup corelib autotests 2011-11-11 02:45:05 +01:00
qset Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qsharedpointer Port externaltests.cpp to QTemporaryDir 2011-12-07 18:58:43 +01:00
qsize Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qsizef Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qstl Cleanup corelib autotests 2011-11-11 02:45:05 +01:00
qstring Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qstringbuilder Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qstringlist Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qstringmatcher Cleanup corelib autotests 2011-11-11 02:45:05 +01:00
qstringref Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qtextboundaryfinder Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qtime Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qtimeline Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qvarlengtharray Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
qvector Remove TESTED_CLASS/TESTED_FILES comments from tests. 2011-12-06 02:19:25 +01:00
tools.pro Introducing QArrayData 2011-12-06 16:57:17 +01:00