summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qpicture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/image/qpicture.cpp')
-rw-r--r--src/gui/image/qpicture.cpp59
1 files changed, 33 insertions, 26 deletions
diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp
index 1136a9728..d8217730a 100644
--- a/src/gui/image/qpicture.cpp
+++ b/src/gui/image/qpicture.cpp
@@ -131,7 +131,6 @@ QPicture::QPicture(int formatVersion)
d_ptr(new QPicturePrivate)
{
Q_D(QPicture);
- d_ptr->q_ptr = this;
if (formatVersion == 0)
qWarning("QPicture: invalid format version 0");
@@ -141,8 +140,7 @@ QPicture::QPicture(int formatVersion)
d->formatMajor = formatVersion;
d->formatMinor = 0;
d->formatOk = false;
- }
- else {
+ } else {
d->resetFormat();
}
}
@@ -154,9 +152,8 @@ QPicture::QPicture(int formatVersion)
*/
QPicture::QPicture(const QPicture &pic)
- : QPaintDevice(), d_ptr(pic.d_ptr.data())
+ : QPaintDevice(), d_ptr(pic.d_ptr)
{
- d_func()->ref.ref();
}
/*! \internal */
@@ -164,7 +161,6 @@ QPicture::QPicture(QPicturePrivate &dptr)
: QPaintDevice(),
d_ptr(&dptr)
{
- d_ptr->q_ptr = this;
}
/*!
@@ -225,8 +221,7 @@ const char* QPicture::data() const
void QPicture::detach()
{
- if (d_func()->ref != 1)
- detach_helper();
+ d_ptr.detach();
}
bool QPicture::isDetached() const
@@ -1012,22 +1007,16 @@ int QPicture::metric(PaintDeviceMetric m) const
/*! \fn bool QPicture::isDetached() const
\internal
*/
+
+/*! \internal
+### Qt 5 - remove me
+ */
void QPicture::detach_helper()
{
- Q_D(QPicture);
- QPicturePrivate *x = new QPicturePrivate;
- int pictsize = size();
- x->pictb.setData(data(), pictsize);
- if (d->pictb.isOpen()) {
- x->pictb.open(d->pictb.openMode());
- x->pictb.seek(d->pictb.pos());
- }
- x->trecs = d->trecs;
- x->formatOk = d->formatOk;
- x->formatMinor = d->formatMinor;
- x->brect = d->brect;
- x->override_rect = d->override_rect;
- d_ptr.reset(x);
+ // QExplicitelySharedDataPointer takes care of cloning using
+ // QPicturePrivate's copy constructor. Do not call detach_helper() anymore
+ // and remove in Qt 5, please.
+ Q_ASSERT_X(false, "QPicture::detach_helper()", "Do not call this function");
}
/*!
@@ -1036,7 +1025,7 @@ void QPicture::detach_helper()
*/
QPicture& QPicture::operator=(const QPicture &p)
{
- d_ptr.assign(p.d_ptr.data());
+ d_ptr = p.d_ptr;
return *this;
}
@@ -1046,10 +1035,28 @@ QPicture& QPicture::operator=(const QPicture &p)
Constructs a QPicturePrivate
*/
QPicturePrivate::QPicturePrivate()
- : in_memory_only(false),
- q_ptr(0)
+ : in_memory_only(false)
{
- ref = 1;
+}
+
+/*!
+ \internal
+
+ Copy-Constructs a QPicturePrivate. Needed when detaching.
+*/
+QPicturePrivate::QPicturePrivate(const QPicturePrivate &other)
+ : trecs(other.trecs),
+ formatOk(other.formatOk),
+ formatMinor(other.formatMinor),
+ brect(other.brect),
+ override_rect(other.override_rect),
+ in_memory_only(false)
+{
+ pictb.setData(other.pictb.data(), other.pictb.size());
+ if (other.pictb.isOpen()) {
+ pictb.open(other.pictb.openMode());
+ pictb.seek(other.pictb.pos());
+ }
}
/*!