diff options
author | Jason Barron <jbarron@trolltech.com> | 2009-08-20 15:50:20 (GMT) |
---|---|---|
committer | Jason Barron <jbarron@trolltech.com> | 2009-08-20 15:50:20 (GMT) |
commit | 79a5babcd2fdee3aca7fb6b13d9eddd2ec130581 (patch) | |
tree | 48146ff0a0dc09ad80b317df83e3ec646c229aa3 | |
parent | e93ffdbb6fde611defc34fd27aec25c40da5a60e (diff) | |
parent | 63a6395e6bd24a3bd11425c6a978a111f53ebf99 (diff) | |
download | Qt-79a5babcd2fdee3aca7fb6b13d9eddd2ec130581.zip Qt-79a5babcd2fdee3aca7fb6b13d9eddd2ec130581.tar.gz Qt-79a5babcd2fdee3aca7fb6b13d9eddd2ec130581.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt-s60-public
30 files changed, 114 insertions, 145 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 6722418..7dbbc1b 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -2026,7 +2026,7 @@ inline void qSwap(T &value1, T &value2) template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \ template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \ { \ - qSwap<TYPE::DataPtr>(value1.data_ptr(), value2.data_ptr()); \ + qSwap(value1.data_ptr(), value2.data_ptr()); \ } /* diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 8b9d202..ecb0bcb 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -2231,9 +2231,8 @@ QDateTime::QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec) */ QDateTime::QDateTime(const QDateTime &other) - : d(other.d.data()) + : d(other.d) { - d->ref.ref(); } /*! @@ -2250,7 +2249,7 @@ QDateTime::~QDateTime() QDateTime &QDateTime::operator=(const QDateTime &other) { - d.assign(other.d.data()); + d = other.d; return *this; } diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h index 84d3e83..988d1a2 100644 --- a/src/corelib/tools/qdatetime.h +++ b/src/corelib/tools/qdatetime.h @@ -44,7 +44,7 @@ #include <QtCore/qstring.h> #include <QtCore/qnamespace.h> -#include <QtCore/qscopedpointer.h> +#include <QtCore/qsharedpointer.h> QT_BEGIN_HEADER @@ -285,7 +285,7 @@ public: private: friend class QDateTimePrivate; void detach(); - QScopedSharedPointer<QDateTimePrivate> d; + QExplicitlySharedDataPointer<QDateTimePrivate> d; #ifndef QT_NO_DATASTREAM friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QDateTime &); diff --git a/src/corelib/tools/qdatetime_p.h b/src/corelib/tools/qdatetime_p.h index 0284ed1..227e4fb 100644 --- a/src/corelib/tools/qdatetime_p.h +++ b/src/corelib/tools/qdatetime_p.h @@ -81,9 +81,9 @@ class QDateTimePrivate public: enum Spec { LocalUnknown = -1, LocalStandard = 0, LocalDST = 1, UTC = 2, OffsetFromUTC = 3}; - QDateTimePrivate() : ref(1), spec(LocalUnknown), utcOffset(0) {} + QDateTimePrivate() : spec(LocalUnknown), utcOffset(0) {} QDateTimePrivate(const QDateTimePrivate &other) - : ref(1), date(other.date), time(other.time), spec(other.spec), utcOffset(other.utcOffset) + : date(other.date), time(other.time), spec(other.spec), utcOffset(other.utcOffset) {} QAtomicInt ref; diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h index dde6e88..8aace0f 100644 --- a/src/corelib/tools/qshareddata.h +++ b/src/corelib/tools/qshareddata.h @@ -69,6 +69,9 @@ private: template <class T> class QSharedDataPointer { public: + typedef T Type; + typedef T *pointer; + inline void detach() { if (d && d->ref != 1) detach_helper(); } inline T &operator*() { detach(); return *d; } inline const T &operator*() const { return *d; } @@ -127,6 +130,7 @@ template <class T> class QExplicitlySharedDataPointer { public: typedef T Type; + typedef T *pointer; inline T &operator*() const { return *d; } inline T *operator->() { return d; } diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index bce4c64..90ca34f 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -555,10 +555,12 @@ public: inline QWeakPointer() : d(0), value(0) { } inline ~QWeakPointer() { if (d && !d->weakref.deref()) delete d; } +#ifndef QT_NO_QOBJECT // special constructor that is enabled only if X derives from QObject template <class X> inline QWeakPointer(X *ptr) : d(ptr ? d->getAndRef(ptr) : 0), value(ptr) { } +#endif template <class X> inline QWeakPointer &operator=(X *ptr) { return *this = QWeakPointer(ptr); } diff --git a/src/gui/image/qbitmap.h b/src/gui/image/qbitmap.h index 8738d65..89d3171 100644 --- a/src/gui/image/qbitmap.h +++ b/src/gui/image/qbitmap.h @@ -82,6 +82,8 @@ public: QT3_SUPPORT_CONSTRUCTOR QBitmap(const QImage &image) { *this = fromImage(image); } QT3_SUPPORT QBitmap &operator=(const QImage &image) { *this = fromImage(image); return *this; } #endif + + typedef QExplicitlySharedDataPointer<QPixmapData> DataPtr; }; Q_DECLARE_SHARED(QBitmap) diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp index 1136a97..d821773 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()); + } } /*! diff --git a/src/gui/image/qpicture.h b/src/gui/image/qpicture.h index 1e80ab7..6effae7 100644 --- a/src/gui/image/qpicture.h +++ b/src/gui/image/qpicture.h @@ -42,8 +42,9 @@ #ifndef QPICTURE_H #define QPICTURE_H -#include <QtGui/qpaintdevice.h> #include <QtCore/qstringlist.h> +#include <QtCore/qsharedpointer.h> +#include <QtGui/qpaintdevice.h> QT_BEGIN_HEADER @@ -106,15 +107,15 @@ private: bool exec(QPainter *p, QDataStream &ds, int i); void detach_helper(); - QScopedSharedPointer<QPicturePrivate> d_ptr; + QExplicitlySharedDataPointer<QPicturePrivate> d_ptr; friend class QPicturePaintEngine; friend class Q3Picture; friend class QAlphaPaintEngine; friend class QPreviewPaintEngine; public: - typedef QPicturePrivate* DataPtr; - inline DataPtr &data_ptr() { return d_ptr.data_ptr(); } + typedef QExplicitlySharedDataPointer<QPicturePrivate> DataPtr; + inline DataPtr &data_ptr() { return d_ptr; } }; Q_DECLARE_SHARED(QPicture) diff --git a/src/gui/image/qpicture_p.h b/src/gui/image/qpicture_p.h index f405d7f..0ab181c 100644 --- a/src/gui/image/qpicture_p.h +++ b/src/gui/image/qpicture_p.h @@ -71,7 +71,6 @@ extern const char *qt_mfhdr_tag; class QPicturePrivate { - Q_DECLARE_PUBLIC(QPicture) friend class QPicturePaintEngine; friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &s, const QPicture &r); friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &s, QPicture &r); @@ -144,6 +143,7 @@ public: }; QPicturePrivate(); + QPicturePrivate(const QPicturePrivate &other); QAtomicInt ref; bool checkFormat(); @@ -162,8 +162,6 @@ public: QList<QPixmap> pixmap_list; QList<QBrush> brush_list; QList<QPen> pen_list; - - QPicture *q_ptr; }; QT_END_NAMESPACE diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 79b1f17..7328853 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -120,7 +120,6 @@ void QPixmap::init(int w, int h, int type) data = QGraphicsSystem::createDefaultPixmapData(static_cast<QPixmapData::PixelType>(type)); data->resize(w, h); - data->ref.ref(); } /*! @@ -222,7 +221,6 @@ QPixmap::QPixmap(const QSize &s, int type) QPixmap::QPixmap(QPixmapData *d) : QPaintDevice(), data(d) { - data->ref.ref(); } /*! @@ -261,12 +259,7 @@ QPixmap::QPixmap(const QString& fileName, const char *format, Qt::ImageConversio if (!qt_pixmap_thread_test()) return; - QT_TRY { - load(fileName, format, flags); - } QT_CATCH(...) { - deref(); - QT_RETHROW; - } + load(fileName, format, flags); } /*! @@ -283,11 +276,9 @@ QPixmap::QPixmap(const QPixmap &pixmap) return; } if (pixmap.paintingActive()) { // make a deep copy - data = 0; operator=(pixmap.copy()); } else { data = pixmap.data; - data->ref.ref(); } } @@ -314,17 +305,12 @@ QPixmap::QPixmap(const char * const xpm[]) if (!xpm) return; - QT_TRY { - QImage image(xpm); - if (!image.isNull()) { - if (data->pixelType() == QPixmapData::BitmapType) - *this = QBitmap::fromImage(image); - else - *this = fromImage(image); - } - } QT_CATCH(...) { - deref(); - QT_RETHROW; + QImage image(xpm); + if (!image.isNull()) { + if (data->pixelType() == QPixmapData::BitmapType) + *this = QBitmap::fromImage(image); + else + *this = fromImage(image); } } #endif @@ -336,7 +322,6 @@ QPixmap::QPixmap(const char * const xpm[]) QPixmap::~QPixmap() { - deref(); } /*! @@ -381,7 +366,7 @@ QPixmap QPixmap::copy(const QRect &rect) const else d = QGraphicsSystem::createDefaultPixmapData(data->pixelType()); - d->copy(data, r); + d->copy(data.data(), r); return QPixmap(d); } @@ -454,8 +439,6 @@ QPixmap &QPixmap::operator=(const QPixmap &pixmap) if (pixmap.paintingActive()) { // make a deep copy *this = pixmap.copy(); } else { - pixmap.data->ref.ref(); // avoid 'x = x' - deref(); data = pixmap.data; } return *this; @@ -1362,14 +1345,12 @@ bool QPixmap::isDetached() const return data->ref == 1; } +/*! \internal + ### Qt5 - remove me. +*/ void QPixmap::deref() { - if (data && !data->ref.deref()) { // Destroy image if last ref - if (data->is_cached) - QImagePixmapCleanupHooks::executePixmapHooks(this); - delete data; - data = 0; - } + Q_ASSERT_X(false, "QPixmap::deref()", "Do not call this function anymore!"); } /*! @@ -1928,7 +1909,7 @@ void QPixmap::detach() { QPixmapData::ClassId id = data->classId(); if (id == QPixmapData::RasterClass) { - QRasterPixmapData *rasterData = static_cast<QRasterPixmapData*>(data); + QRasterPixmapData *rasterData = static_cast<QRasterPixmapData*>(data.data()); rasterData->image.detach(); } @@ -2038,7 +2019,7 @@ QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags) */ QPixmapData* QPixmap::pixmapData() const { - return data; + return data.data(); } /*! diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index bce1f5e..961008f 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -46,6 +46,7 @@ #include <QtGui/qcolor.h> #include <QtCore/qnamespace.h> #include <QtCore/qstring.h> // char*->QString conversion +#include <QtCore/qsharedpointer.h> #include <QtGui/qimage.h> #include <QtGui/qtransform.h> @@ -227,7 +228,7 @@ public: #endif private: - QPixmapData *data; + QExplicitlySharedDataPointer<QPixmapData> data; bool doImageIO(QImageWriter *io, int quality) const; @@ -272,7 +273,7 @@ public: QPixmapData* pixmapData() const; public: - typedef QPixmapData * DataPtr; + typedef QExplicitlySharedDataPointer<QPixmapData> DataPtr; inline DataPtr &data_ptr() { return data; } }; diff --git a/src/gui/image/qpixmap_qws.cpp b/src/gui/image/qpixmap_qws.cpp index b106610..e549900 100644 --- a/src/gui/image/qpixmap_qws.cpp +++ b/src/gui/image/qpixmap_qws.cpp @@ -112,7 +112,7 @@ QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h) QRgb* QPixmap::clut() const { if (data->classId() == QPixmapData::RasterClass) { - const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data); + const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data.data()); return d->image.colorTable().data(); } @@ -122,7 +122,7 @@ QRgb* QPixmap::clut() const int QPixmap::numCols() const { if (data->classId() == QPixmapData::RasterClass) { - const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data); + const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data.data()); return d->image.numColors(); } @@ -132,7 +132,7 @@ int QPixmap::numCols() const const uchar* QPixmap::qwsBits() const { if (data->classId() == QPixmapData::RasterClass) { - const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data); + const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data.data()); return d->image.bits(); } @@ -142,7 +142,7 @@ const uchar* QPixmap::qwsBits() const int QPixmap::qwsBytesPerLine() const { if (data->classId() == QPixmapData::RasterClass) { - const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data); + const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data.data()); return d->image.bytesPerLine(); } diff --git a/src/gui/image/qpixmapcache_p.h b/src/gui/image/qpixmapcache_p.h index cbfc3e8..511c852 100644 --- a/src/gui/image/qpixmapcache_p.h +++ b/src/gui/image/qpixmapcache_p.h @@ -82,7 +82,7 @@ public: QDetachedPixmap(const QPixmap &pix) : QPixmap(pix) { if (data && data->classId() == QPixmapData::RasterClass) { - QRasterPixmapData *d = static_cast<QRasterPixmapData*>(data); + QRasterPixmapData *d = static_cast<QRasterPixmapData*>(data.data()); if (!d->image.isNull() && d->image.d->paintEngine && !d->image.d->paintEngine->isActive()) { diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h index 1c3e422..70890c0 100644 --- a/src/gui/image/qpixmapdata_p.h +++ b/src/gui/image/qpixmapdata_p.h @@ -117,6 +117,7 @@ private: friend class QGLContextPrivate; friend class QX11PixmapData; friend class QGLTextureCache; //Needs to check the reference count + friend class QExplicitlySharedDataPointer<QPixmapData>; QAtomicInt ref; int detach_no; diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 8679e15..72bb164 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -2368,7 +2368,7 @@ void QRasterPaintEngine::drawPixmap(const QPointF &pos, const QPixmap &pixmap) #endif if (pixmap.data->classId() == QPixmapData::RasterClass) { - const QImage &image = ((QRasterPixmapData *) pixmap.data)->image; + const QImage &image = static_cast<QRasterPixmapData *>(pixmap.data.data())->image; if (image.depth() == 1) { Q_D(QRasterPaintEngine); QRasterPaintEngineState *s = state(); @@ -2406,7 +2406,7 @@ void QRasterPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, cons #endif if (pixmap.data->classId() == QPixmapData::RasterClass) { - const QImage &image = ((QRasterPixmapData *) pixmap.data)->image; + const QImage &image = static_cast<QRasterPixmapData *>(pixmap.data.data())->image; if (image.depth() == 1) { Q_D(QRasterPaintEngine); QRasterPaintEngineState *s = state(); @@ -2716,7 +2716,7 @@ void QRasterPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, QImage image; if (pixmap.data->classId() == QPixmapData::RasterClass) { - image = ((QRasterPixmapData *) pixmap.data)->image; + image = static_cast<QRasterPixmapData *>(pixmap.data.data())->image; } else { image = pixmap.toImage(); } diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 96905d0..3443a64 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -217,7 +217,6 @@ QFontPrivate::QFontPrivate() rawMode(false), underline(false), overline(false), strikeOut(false), kerning(true), capital(0), letterSpacingIsAbsolute(false), scFont(0) { - ref = 1; #ifdef Q_WS_X11 if (QX11Info::display()) screen = QX11Info::appScreen(); @@ -237,7 +236,6 @@ QFontPrivate::QFontPrivate(const QFontPrivate &other) letterSpacing(other.letterSpacing), wordSpacing(other.wordSpacing), scFont(other.scFont) { - ref = 1; #ifdef Q_WS_WIN hdc = other.hdc; #endif @@ -721,11 +719,11 @@ QFont::QFont(const QFont &font, QPaintDevice *pd) const int screen = 0; #endif if (font.d->dpi != dpi || font.d->screen != screen ) { - d.reset(new QFontPrivate(*font.d)); + d = new QFontPrivate(*font.d); d->dpi = dpi; d->screen = screen; } else { - d.assign(font.d.data()); + d = font.d.data(); } #ifdef Q_WS_WIN if (pd->devType() == QInternal::Printer && pd->getDC()) @@ -737,9 +735,8 @@ QFont::QFont(const QFont &font, QPaintDevice *pd) \internal */ QFont::QFont(QFontPrivate *data) - : resolve_mask(QFont::AllPropertiesResolved) + : d(data), resolve_mask(QFont::AllPropertiesResolved) { - d.assign(data); } /*! \internal @@ -766,9 +763,8 @@ void QFont::detach() \sa QApplication::setFont(), QApplication::font() */ QFont::QFont() - :resolve_mask(0) + : d(QApplication::font().d.data()), resolve_mask(0) { - d.assign(QApplication::font().d.data()); } /*! @@ -790,10 +786,8 @@ QFont::QFont() setStyleHint() QApplication::font() */ QFont::QFont(const QString &family, int pointSize, int weight, bool italic) + : d(new QFontPrivate()), resolve_mask(QFont::FamilyResolved) { - d.reset(new QFontPrivate()); - resolve_mask = QFont::FamilyResolved; - if (pointSize <= 0) { #ifdef Q_OS_SYMBIAN pointSize = 7; @@ -821,9 +815,8 @@ QFont::QFont(const QString &family, int pointSize, int weight, bool italic) Constructs a font that is a copy of \a font. */ QFont::QFont(const QFont &font) + : d(font.d.data()), resolve_mask(font.resolve_mask) { - d.assign(font.d.data()); - resolve_mask = font.resolve_mask; } /*! @@ -838,7 +831,7 @@ QFont::~QFont() */ QFont &QFont::operator=(const QFont &font) { - d.assign(font.d.data()); + d = font.d.data(); resolve_mask = font.resolve_mask; return *this; } @@ -2197,8 +2190,7 @@ QDataStream &operator<<(QDataStream &s, const QFont &font) */ QDataStream &operator>>(QDataStream &s, QFont &font) { - font.d.assign(0); - font.d.reset(new QFontPrivate); + font.d = new QFontPrivate; font.resolve_mask = QFont::AllPropertiesResolved; quint8 styleHint, styleStrategy = QFont::PreferDefault, charSet, weight, bits; diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h index 10ec062..e91e017 100644 --- a/src/gui/text/qfont.h +++ b/src/gui/text/qfont.h @@ -44,7 +44,7 @@ #include <QtGui/qwindowdefs.h> #include <QtCore/qstring.h> -#include <QtCore/qscopedpointer.h> +#include <QtCore/qsharedpointer.h> #if defined(Q_WS_X11) || defined(Q_WS_QWS) typedef struct FT_FaceRec_* FT_Face; @@ -313,7 +313,7 @@ private: friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QFont &); #endif - QScopedSharedPointer<QFontPrivate> d; + QExplicitlySharedDataPointer<QFontPrivate> d; uint resolve_mask; }; diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index 2ea6d9f..a09b8c43 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -159,9 +159,8 @@ QSslCertificate::QSslCertificate(const QByteArray &data, QSsl::EncodingFormat fo /*! Constructs an identical copy of \a other. */ -QSslCertificate::QSslCertificate(const QSslCertificate &other) : d(other.d.data()) +QSslCertificate::QSslCertificate(const QSslCertificate &other) : d(other.d) { - d->ref.ref(); } /*! @@ -177,7 +176,7 @@ QSslCertificate::~QSslCertificate() */ QSslCertificate &QSslCertificate::operator=(const QSslCertificate &other) { - d.assign(other.d.data()); + d = other.d; return *this; } @@ -243,7 +242,7 @@ void QSslCertificate::clear() { if (isNull()) return; - d.reset(new QSslCertificatePrivate); + d = new QSslCertificatePrivate; } /*! diff --git a/src/network/ssl/qsslcertificate.h b/src/network/ssl/qsslcertificate.h index a62412e..d664434 100644 --- a/src/network/ssl/qsslcertificate.h +++ b/src/network/ssl/qsslcertificate.h @@ -47,6 +47,7 @@ #include <QtCore/qbytearray.h> #include <QtCore/qcryptographichash.h> #include <QtCore/qregexp.h> +#include <QtCore/qsharedpointer.h> #include <QtNetwork/qssl.h> typedef struct x509_st X509; // ### check if this works @@ -118,7 +119,7 @@ public: Qt::HANDLE handle() const; private: - QScopedSharedPointer<QSslCertificatePrivate> d; + QExplicitlySharedDataPointer<QSslCertificatePrivate> d; friend class QSslCertificatePrivate; friend class QSslSocketBackendPrivate; }; diff --git a/src/network/ssl/qsslcertificate_p.h b/src/network/ssl/qsslcertificate_p.h index bae5ad8..0a5bc54 100644 --- a/src/network/ssl/qsslcertificate_p.h +++ b/src/network/ssl/qsslcertificate_p.h @@ -71,7 +71,6 @@ public: : null(true), x509(0) { QSslSocketPrivate::ensureInitialized(); - ref = 1; } ~QSslCertificatePrivate() diff --git a/src/network/ssl/qsslkey.cpp b/src/network/ssl/qsslkey.cpp index 474e5ee..fceeb84 100644 --- a/src/network/ssl/qsslkey.cpp +++ b/src/network/ssl/qsslkey.cpp @@ -269,9 +269,8 @@ QSslKey::QSslKey(QIODevice *device, QSsl::KeyAlgorithm algorithm, QSsl::Encoding /*! Constructs an identical copy of \a other. */ -QSslKey::QSslKey(const QSslKey &other) : d(other.d.data()) +QSslKey::QSslKey(const QSslKey &other) : d(other.d) { - d->ref.ref(); } /*! @@ -289,7 +288,7 @@ QSslKey::~QSslKey() */ QSslKey &QSslKey::operator=(const QSslKey &other) { - d.assign(other.d.data()); + d = other.d; return *this; } @@ -310,13 +309,7 @@ bool QSslKey::isNull() const */ void QSslKey::clear() { - d.reset(new QSslKeyPrivate); - - //### old code: is this really correct??? - //if (!d->ref.deref()) { - // delete d; - // d = new QSslKeyPrivate; - //} + d = new QSslKeyPrivate; } /*! diff --git a/src/network/ssl/qsslkey.h b/src/network/ssl/qsslkey.h index 5132dae..d5a85b3 100644 --- a/src/network/ssl/qsslkey.h +++ b/src/network/ssl/qsslkey.h @@ -45,7 +45,7 @@ #include <QtCore/qnamespace.h> #include <QtCore/qbytearray.h> -#include <QtCore/qscopedpointer.h> +#include <QtCore/qsharedpointer.h> #include <QtNetwork/qssl.h> QT_BEGIN_HEADER @@ -59,7 +59,7 @@ QT_MODULE(Network) template <typename A, typename B> struct QPair; class QIODevice; - + class QSslKeyPrivate; class Q_NETWORK_EXPORT QSslKey { @@ -93,7 +93,7 @@ public: inline bool operator!=(const QSslKey &key) const { return !operator==(key); } private: - QScopedSharedPointer<QSslKeyPrivate> d; + QExplicitlySharedDataPointer<QSslKeyPrivate> d; friend class QSslCertificate; }; diff --git a/src/network/ssl/qsslkey_p.h b/src/network/ssl/qsslkey_p.h index fe7f198..df5d7b2 100644 --- a/src/network/ssl/qsslkey_p.h +++ b/src/network/ssl/qsslkey_p.h @@ -69,7 +69,6 @@ public: , dsa(0) { clear(); - ref = 1; } inline ~QSslKeyPrivate() @@ -91,6 +90,9 @@ public: DSA *dsa; QAtomicInt ref; + +private: + Q_DISABLE_COPY(QSslKeyPrivate) }; QT_END_NAMESPACE diff --git a/src/script/qscriptcontextinfo.cpp b/src/script/qscriptcontextinfo.cpp index 6467360..e145394 100644 --- a/src/script/qscriptcontextinfo.cpp +++ b/src/script/qscriptcontextinfo.cpp @@ -207,9 +207,8 @@ QScriptContextInfo::QScriptContextInfo(const QScriptContext *context) : d_ptr(0) { if (context) { - d_ptr.data_ptr() = new QScriptContextInfoPrivate(context); + d_ptr = new QScriptContextInfoPrivate(context); d_ptr->q_ptr = this; - d_ptr->ref.ref(); } } @@ -217,10 +216,8 @@ QScriptContextInfo::QScriptContextInfo(const QScriptContext *context) Constructs a new QScriptContextInfo from the \a other info. */ QScriptContextInfo::QScriptContextInfo(const QScriptContextInfo &other) - : d_ptr(other.d_ptr.data()) + : d_ptr(other.d_ptr) { - if (d_ptr) - d_ptr->ref.ref(); } /*! @@ -246,7 +243,7 @@ QScriptContextInfo::~QScriptContextInfo() */ QScriptContextInfo &QScriptContextInfo::operator=(const QScriptContextInfo &other) { - d_ptr.assign(other.d_ptr.data()); + d_ptr = other.d_ptr; return *this; } @@ -497,8 +494,7 @@ QDataStream &operator<<(QDataStream &out, const QScriptContextInfo &info) Q_SCRIPT_EXPORT QDataStream &operator>>(QDataStream &in, QScriptContextInfo &info) { if (!info.d_ptr) { - info.d_ptr.data_ptr() = new QScriptContextInfoPrivate(); - info.d_ptr->ref.ref(); + info.d_ptr = new QScriptContextInfoPrivate(); } in >> info.d_ptr->scriptId; diff --git a/src/script/qscriptcontextinfo.h b/src/script/qscriptcontextinfo.h index 433a308..9cc64ff 100644 --- a/src/script/qscriptcontextinfo.h +++ b/src/script/qscriptcontextinfo.h @@ -48,7 +48,7 @@ #include <QtCore/qlist.h> #include <QtCore/qstringlist.h> -#include <QtCore/qscopedpointer.h> +#include <QtCore/qsharedpointer.h> QT_BEGIN_HEADER @@ -105,7 +105,7 @@ public: bool operator!=(const QScriptContextInfo &other) const; private: - QScopedSharedPointer<QScriptContextInfoPrivate> d_ptr; + QExplicitlySharedDataPointer<QScriptContextInfoPrivate> d_ptr; Q_DECLARE_PRIVATE(QScriptContextInfo) }; diff --git a/src/script/qscriptengine.cpp b/src/script/qscriptengine.cpp index 07fed70..c8e19dd 100644 --- a/src/script/qscriptengine.cpp +++ b/src/script/qscriptengine.cpp @@ -1774,10 +1774,8 @@ QScriptValue QScriptEngine::objectById(qint64 id) const Constructs a new QScriptSyntaxCheckResult from the \a other result. */ QScriptSyntaxCheckResult::QScriptSyntaxCheckResult(const QScriptSyntaxCheckResult &other) - : d_ptr(other.d_ptr.data()) + : d_ptr(other.d_ptr) { - if (d_ptr) - d_ptr->ref.ref(); } /*! @@ -1786,8 +1784,6 @@ QScriptSyntaxCheckResult::QScriptSyntaxCheckResult(const QScriptSyntaxCheckResul QScriptSyntaxCheckResult::QScriptSyntaxCheckResult(QScriptSyntaxCheckResultPrivate *d) : d_ptr(d) { - if (d_ptr) - d_ptr->ref.ref(); } /*! @@ -1856,7 +1852,7 @@ QString QScriptSyntaxCheckResult::errorMessage() const */ QScriptSyntaxCheckResult &QScriptSyntaxCheckResult::operator=(const QScriptSyntaxCheckResult &other) { - d_ptr.assign(other.d_ptr.data()); + d_ptr = other.d_ptr; return *this; } diff --git a/src/script/qscriptengine.h b/src/script/qscriptengine.h index 3cdedd9..62d67ff 100644 --- a/src/script/qscriptengine.h +++ b/src/script/qscriptengine.h @@ -47,7 +47,7 @@ #ifndef QT_NO_SCRIPT #include <QtCore/qvariant.h> -#include <QtCore/qscopedpointer.h> +#include <QtCore/qsharedpointer.h> #ifndef QT_NO_QOBJECT #include <QtCore/qobject.h> @@ -115,7 +115,7 @@ public: private: QScriptSyntaxCheckResult(); QScriptSyntaxCheckResult(QScriptSyntaxCheckResultPrivate *d); - QScopedSharedPointer<QScriptSyntaxCheckResultPrivate> d_ptr; + QExplicitlySharedDataPointer<QScriptSyntaxCheckResultPrivate> d_ptr; Q_DECLARE_PRIVATE(QScriptSyntaxCheckResult) friend class QScriptEnginePrivate; diff --git a/tests/auto/networkselftest/networkselftest.pro b/tests/auto/networkselftest/networkselftest.pro index a2e1adf..ac610de 100644 --- a/tests/auto/networkselftest/networkselftest.pro +++ b/tests/auto/networkselftest/networkselftest.pro @@ -2,5 +2,4 @@ load(qttest_p4) SOURCES += tst_networkselftest.cpp QT = core network -!symbian:DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp index 9e1db10..5e07762 100644 --- a/tests/auto/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/networkselftest/tst_networkselftest.cpp @@ -43,10 +43,6 @@ #include <QtNetwork/QtNetwork> #include "../network-settings.h" -#if defined(Q_OS_SYMBIAN) -#define SRCDIR "" -#endif - class tst_NetworkSelfTest: public QObject { Q_OBJECT |