Go to file
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
bin fixqt4headers: Support renaming from QtDeclarative to QtQuick 2011-12-07 09:33:47 +01:00
config.tests Added '-' parameter to fix strings command using gcc-llvm on Mac OS 10.6 w/ Xcode 4.2. 2011-11-08 01:13:40 +01:00
dist Extend touch events. 2011-12-09 14:15:37 +01:00
doc/src Move snippets from qtdoc. 2011-12-06 22:29:01 +01:00
examples Added multi-screen support to hellowindow example. 2011-12-06 20:14:10 +01:00
lib Initial import from the monolithic Qt. 2011-04-27 12:05:43 +02:00
mkspecs Set QMAKE_*_VERSION_OVERRIDE for all modules. 2011-12-07 12:55:28 +01:00
qmake qmake: Add object_parallel_to_source config option 2011-12-07 12:55:28 +01:00
src Add support for setSharable in RefCount 2012-01-05 13:59:14 +01:00
tests Add support for setSharable in RefCount 2012-01-05 13:59:14 +01:00
tools configure.exe: Build tests by default. 2011-11-29 12:27:16 +01:00
util Accessibility: Add Text::DebugDescription 2011-12-07 11:15:28 +01:00
.gitattributes Added .tag file with Git revision. 2011-05-03 16:23:49 +02:00
.gitignore Add V8 snapshot support 2011-11-22 13:10:56 +01:00
.gitmodules Add QtV8 library to QtBase 2011-08-29 10:16:01 +02:00
.tag Added .tag file with Git revision. 2011-05-03 16:23:49 +02:00
configure document the -force-asserts switch 2011-12-08 15:59:00 +01:00
configure.exe Rebuild configure.exe. 2011-12-01 19:18:34 +01:00
header.BSD Initial import from the monolithic Qt. 2011-04-27 12:05:43 +02:00
header.FDL Update licenseheader text in source files for qtbase Qt module 2011-05-24 12:34:08 +03:00
header.LGPL Update licenseheader text in source files for qtbase Qt module 2011-05-24 12:34:08 +03:00
header.LGPL-ONLY Initial import from the monolithic Qt. 2011-04-27 12:05:43 +02:00
INSTALL Initial import from the monolithic Qt. 2011-04-27 12:05:43 +02:00
LGPL_EXCEPTION.txt Initial import from the monolithic Qt. 2011-04-27 12:05:43 +02:00
LICENSE.FDL Initial import from the monolithic Qt. 2011-04-27 12:05:43 +02:00
LICENSE.LGPL Initial import from the monolithic Qt. 2011-04-27 12:05:43 +02:00
LICENSE.PREVIEW.COMMERCIAL Initial import from the monolithic Qt. 2011-04-27 12:05:43 +02:00
qtbase.pro Ensure qmodule.pri is installed. 2011-11-23 00:12:03 +01:00
sync.profile Fix source incompatibility for QVariant{Map, Hash, List} 2011-11-14 18:41:17 +01:00