From ddf4b378f1e7eac62bd504a1e453cb7b894e21f2 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 25 Feb 2012 12:40:20 +0100 Subject: Inline and mark as deprecated images's serialNumber() These function are marked as obsolete since Qt 4.3 The motivation here was too fix QPixmap::serialNumber which is marked as QT_DEPRECATED_SINCE but was not inlined. But then I took the oportunity to do the same with all the other functions. Change-Id: Ic50a7857461fc402b2f2b4528c83e53e8e28ea30 Reviewed-by: Lars Knoll --- src/gui/image/qimage.cpp | 11 ++--------- src/gui/image/qimage.h | 4 +++- src/gui/image/qpixmap.cpp | 9 ++------- src/gui/image/qpixmap.h | 2 +- src/gui/image/qpixmap_raster.cpp | 4 ++-- src/gui/kernel/qpalette.cpp | 7 ++----- src/gui/kernel/qpalette.h | 4 +++- src/gui/text/qtextcursor.cpp | 2 +- 8 files changed, 16 insertions(+), 27 deletions(-) (limited to 'src/gui') diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 5b23dbf4dc..23d212cc92 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -5132,7 +5132,8 @@ bool qt_xForm_helper(const QTransform &trueMat, int xoffset, int type, int depth #undef IWX_LSB #undef IWX_PIX -/*! \obsolete +/*! \fn int QImage::serialNumber() const + \obsolete Returns a number that identifies the contents of this QImage object. Distinct QImage objects can only have the same serial number if they refer to the same contents (but they don't @@ -5147,14 +5148,6 @@ bool qt_xForm_helper(const QTransform &trueMat, int xoffset, int type, int depth \sa operator==() */ -int QImage::serialNumber() const -{ - if (!d) - return 0; - else - return d->ser_no; -} - /*! Returns a number that identifies the contents of this QImage object. Distinct QImage objects can only have the same key if they diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 5a3ae8f886..e9192f1031 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -253,7 +253,9 @@ public: inline static QImage fromData(const QByteArray &data, const char *format = 0) { return fromData(reinterpret_cast(data.constData()), data.size(), format); } - int serialNumber() const; +#if QT_DEPRECATED_SINCE(5, 0) + QT_DEPRECATED inline int serialNumber() const { return cacheKey() >> 32; } +#endif qint64 cacheKey() const; QPaintEngine *paintEngine() const; diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index e8c1304b74..1f325f5b6b 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -885,7 +885,8 @@ void QPixmap::fill(const QColor &color) data->fill(color); } -/*! \obsolete +/*! \fn int QPixmap::serialNumber() const + \obsolete Returns a number that identifies the contents of this QPixmap object. Distinct QPixmap objects can only have the same serial number if they refer to the same contents (but they don't have @@ -898,12 +899,6 @@ void QPixmap::fill(const QColor &color) it as a cache key. For caching pixmaps, we recommend using the QPixmapCache class whenever possible. */ -int QPixmap::serialNumber() const -{ - if (isNull()) - return 0; - return data->serialNumber(); -} /*! Returns a number that identifies this QPixmap. Distinct QPixmap diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index 27bfe15688..3d78a43917 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -146,7 +146,7 @@ public: void scroll(int dx, int dy, const QRect &rect, QRegion *exposed = 0); #if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED int serialNumber() const; + QT_DEPRECATED inline int serialNumber() const { return cacheKey() >> 32; } #endif qint64 cacheKey() const; diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp index 8125b1360d..7c7c4652e3 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -115,7 +115,7 @@ void QRasterPlatformPixmap::resize(int width, int height) image.setColor(1, QColor(Qt::color1).rgba()); } - setSerialNumber(image.serialNumber()); + setSerialNumber(image.cacheKey() >> 32); } bool QRasterPlatformPixmap::fromData(const uchar *buffer, uint len, const char *format, @@ -349,7 +349,7 @@ void QRasterPlatformPixmap::createPixmapForImage(QImage &sourceImage, Qt::ImageC } is_null = (w <= 0 || h <= 0); - setSerialNumber(image.serialNumber()); + setSerialNumber(image.cacheKey() >> 32); } QImage* QRasterPlatformPixmap::buffer() diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp index 6d3d1c9580..90d96674bc 100644 --- a/src/gui/kernel/qpalette.cpp +++ b/src/gui/kernel/qpalette.cpp @@ -844,7 +844,8 @@ bool QPalette::isEqual(QPalette::ColorGroup group1, QPalette::ColorGroup group2) return true; } -/*! \obsolete +/*! \fn int QPalette::serialNumber() const + \obsolete Returns a number that identifies the contents of this QPalette object. Distinct QPalette objects can only have the same serial @@ -860,10 +861,6 @@ bool QPalette::isEqual(QPalette::ColorGroup group1, QPalette::ColorGroup group2) \sa operator==() */ -int QPalette::serialNumber() const -{ - return d->ser_no; -} /*! Returns a number that identifies the contents of this QPalette diff --git a/src/gui/kernel/qpalette.h b/src/gui/kernel/qpalette.h index cc710fa67a..ca619a89b4 100644 --- a/src/gui/kernel/qpalette.h +++ b/src/gui/kernel/qpalette.h @@ -139,7 +139,9 @@ public: inline bool operator!=(const QPalette &p) const { return !(operator==(p)); } bool isCopyOf(const QPalette &p) const; - int serialNumber() const; +#if QT_DEPRECATED_SINCE(5, 0) + QT_DEPRECATED inline int serialNumber() const { return cacheKey() >> 32; } +#endif qint64 cacheKey() const; QPalette resolve(const QPalette &) const; diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index ddf2fb080e..cbffc4315f 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -2325,7 +2325,7 @@ void QTextCursor::insertImage(const QImage &image, const QString &name) } QString imageName = name; if (name.isEmpty()) - imageName = QString::number(image.serialNumber()); + imageName = QString::number(image.cacheKey()); d->priv->document()->addResource(QTextDocument::ImageResource, QUrl(imageName), image); QTextImageFormat format; format.setName(imageName); -- cgit v1.2.3 From 643fd1afdd4b83641e08cc8db04b17416d835121 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 26 Feb 2012 11:53:56 +0100 Subject: QFontEngine: remove unused and buggy grayPalette() QFontEngine::grayPalette() mistakenly returns an empty vector, so even if there's a user (the class it exported, after all), it cannot correctly use it. So, just remove it. Change-Id: Id5f70139e5f6ed9a2a3f28400cd0750d14cb7dc0 Reviewed-by: Olivier Goffart Reviewed-by: Jiang Jiang --- src/gui/text/qfontengine.cpp | 19 ------------------- src/gui/text/qfontengine_p.h | 1 - 2 files changed, 20 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index a084a3dd8c..4bceb28ef7 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1148,25 +1148,6 @@ QByteArray QFontEngine::convertToPostscriptFontFamilyName(const QByteArray &fami return f; } -class QRgbGreyPalette: public QVector -{ -public: - QRgbGreyPalette() - { - resize(256); - QRgb *it = data(); - for (int i = 0; i < size(); ++i, ++it) - *it = 0xff000000 | i | (i<<8) | (i<<16); - } -}; - -Q_GLOBAL_STATIC(QVector, qt_grayPalette) - -const QVector &QFontEngine::grayPalette() -{ - return *qt_grayPalette(); -} - QFixed QFontEngine::lastRightBearing(const QGlyphLayout &glyphs, bool round) { if (glyphs.numGlyphs >= 1) { diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 023882d560..cf9c26f2a4 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -278,7 +278,6 @@ public: int m_subPixelPositionCount; // Number of positions within a single pixel for this cache protected: - static const QVector &grayPalette(); QFixed lastRightBearing(const QGlyphLayout &glyphs, bool round = false); private: -- cgit v1.2.3 From 6c1bdc1854a7700c2b3a345b95f6a2fdca84037d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 23 Feb 2012 22:40:01 +0100 Subject: QFontMetrics: make conversion from QFont to QFontMetrics explicit There is no user of this in qtbase, and I don't think this is a desireable feature anyway. Change-Id: Ifebba5872b0eadb0daba3c3cd5f8b19abeed5c12 Reviewed-by: Lars Knoll Reviewed-by: Olivier Goffart --- src/gui/text/qfontmetrics.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qfontmetrics.h b/src/gui/text/qfontmetrics.h index 7ddc8975e4..e48460ffd0 100644 --- a/src/gui/text/qfontmetrics.h +++ b/src/gui/text/qfontmetrics.h @@ -61,7 +61,7 @@ class QRect; class Q_GUI_EXPORT QFontMetrics { public: - QFontMetrics(const QFont &); + explicit QFontMetrics(const QFont &); QFontMetrics(const QFont &, QPaintDevice *pd); QFontMetrics(const QFontMetrics &); ~QFontMetrics(); @@ -127,7 +127,7 @@ private: class Q_GUI_EXPORT QFontMetricsF { public: - QFontMetricsF(const QFont &); + explicit QFontMetricsF(const QFont &); QFontMetricsF(const QFont &, QPaintDevice *pd); QFontMetricsF(const QFontMetrics &); QFontMetricsF(const QFontMetricsF &); -- cgit v1.2.3 From 612152fad8f531e66ecda9ef72eae32061af7139 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 27 Feb 2012 21:57:12 +0100 Subject: Make qobject_p.h not need qvariant.h. Move definition of ExtraData to the implementation file. As a side effect, we need to include qhash.h in some other places. Change-Id: I8bb4ec0940ae51c7d6961c9a51adb80fd444e1e3 Reviewed-by: Olivier Goffart --- src/gui/kernel/qopenglcontext_p.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h index 3e2c35f088..d5c4d6c762 100644 --- a/src/gui/kernel/qopenglcontext_p.h +++ b/src/gui/kernel/qopenglcontext_p.h @@ -49,9 +49,7 @@ #include #include -#ifndef QT_NO_DEBUG #include -#endif QT_BEGIN_HEADER -- cgit v1.2.3 From 1cd4d6b1819f67b70dd359c7fc43ab06182cc34b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 29 Feb 2012 00:00:27 +0100 Subject: QEvent (and subclasses): make ctors explicit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do this regardless of whether the event subclass is public API or only used in examples. Examples are examples, used by others as templates or even copied verbatim, so they should also follow sound engineering rules. Anyway, there's only one in examples/... Change-Id: I586ff16407a956c9e89288fdd4377eed73f45c0f Reviewed-by: Samuel Rødal --- src/gui/kernel/qevent.h | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index ca93095a94..feee7fa837 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -71,7 +71,7 @@ class QScreen; class Q_GUI_EXPORT QInputEvent : public QEvent { public: - QInputEvent(Type type, Qt::KeyboardModifiers modifiers = Qt::NoModifier); + explicit QInputEvent(Type type, Qt::KeyboardModifiers modifiers = Qt::NoModifier); ~QInputEvent(); inline Qt::KeyboardModifiers modifiers() const { return modState; } inline void setModifiers(Qt::KeyboardModifiers amodifiers) { modState = amodifiers; } @@ -276,7 +276,7 @@ protected: class Q_GUI_EXPORT QFocusEvent : public QEvent { public: - QFocusEvent(Type type, Qt::FocusReason reason=Qt::OtherFocusReason); + explicit QFocusEvent(Type type, Qt::FocusReason reason=Qt::OtherFocusReason); ~QFocusEvent(); inline bool gotFocus() const { return type() == FocusIn; } @@ -292,8 +292,8 @@ private: class Q_GUI_EXPORT QPaintEvent : public QEvent { public: - QPaintEvent(const QRegion& paintRegion); - QPaintEvent(const QRect &paintRect); + explicit QPaintEvent(const QRegion& paintRegion); + explicit QPaintEvent(const QRect &paintRect); ~QPaintEvent(); inline const QRect &rect() const { return m_rect; } @@ -311,7 +311,7 @@ protected: class Q_GUI_EXPORT QUpdateLaterEvent : public QEvent { public: - QUpdateLaterEvent(const QRegion& paintRegion); + explicit QUpdateLaterEvent(const QRegion& paintRegion); ~QUpdateLaterEvent(); inline const QRegion ®ion() const { return m_region; } @@ -337,7 +337,7 @@ protected: class Q_GUI_EXPORT QExposeEvent : public QEvent { public: - QExposeEvent(const QRegion &rgn); + explicit QExposeEvent(const QRegion &rgn); ~QExposeEvent(); inline const QRegion ®ion() const { return rgn; } @@ -468,7 +468,7 @@ private: class Q_GUI_EXPORT QInputMethodQueryEvent : public QEvent { public: - QInputMethodQueryEvent(Qt::InputMethodQueries queries); + explicit QInputMethodQueryEvent(Qt::InputMethodQueries queries); ~QInputMethodQueryEvent(); Qt::InputMethodQueries queries() const { return m_queries; } @@ -586,7 +586,7 @@ private: class Q_GUI_EXPORT QStatusTipEvent : public QEvent { public: - QStatusTipEvent(const QString &tip); + explicit QStatusTipEvent(const QString &tip); ~QStatusTipEvent(); inline QString tip() const { return s; } @@ -599,7 +599,7 @@ private: class Q_GUI_EXPORT QWhatsThisClickedEvent : public QEvent { public: - QWhatsThisClickedEvent(const QString &href); + explicit QWhatsThisClickedEvent(const QString &href); ~QWhatsThisClickedEvent(); inline QString href() const { return s; } @@ -624,8 +624,8 @@ public: class Q_GUI_EXPORT QFileOpenEvent : public QEvent { public: - QFileOpenEvent(const QString &file); - QFileOpenEvent(const QUrl &url); + explicit QFileOpenEvent(const QString &file); + explicit QFileOpenEvent(const QUrl &url); ~QFileOpenEvent(); inline QString file() const { return f; } @@ -639,7 +639,7 @@ private: class Q_GUI_EXPORT QToolBarChangeEvent : public QEvent { public: - QToolBarChangeEvent(bool t); + explicit QToolBarChangeEvent(bool t); ~QToolBarChangeEvent(); inline bool toggle() const { return tog; } @@ -669,7 +669,7 @@ protected: class Q_GUI_EXPORT QClipboardEvent : public QEvent { public: - QClipboardEvent(QEventPrivate *data); + explicit QClipboardEvent(QEventPrivate *data); ~QClipboardEvent(); QEventPrivate *data() { return d; } @@ -679,7 +679,7 @@ public: class Q_GUI_EXPORT QWindowStateChangeEvent: public QEvent { public: - QWindowStateChangeEvent(Qt::WindowStates aOldState); + explicit QWindowStateChangeEvent(Qt::WindowStates aOldState); QWindowStateChangeEvent(Qt::WindowStates aOldState, bool isOverride); ~QWindowStateChangeEvent(); @@ -711,7 +711,7 @@ public: }; Q_DECLARE_FLAGS(InfoFlags, InfoFlag) - TouchPoint(int id = -1); + explicit TouchPoint(int id = -1); TouchPoint(const QTouchEvent::TouchPoint &other); ~TouchPoint(); @@ -783,11 +783,11 @@ public: }; #endif - QTouchEvent(QEvent::Type eventType, - QTouchDevice *device = 0, - Qt::KeyboardModifiers modifiers = Qt::NoModifier, - Qt::TouchPointStates touchPointStates = 0, - const QList &touchPoints = QList()); + explicit QTouchEvent(QEvent::Type eventType, + QTouchDevice *device = 0, + Qt::KeyboardModifiers modifiers = Qt::NoModifier, + Qt::TouchPointStates touchPointStates = 0, + const QList &touchPoints = QList()); ~QTouchEvent(); inline QWindow *window() const { return _window; } @@ -825,7 +825,7 @@ class QScrollPrepareEventPrivate; class Q_GUI_EXPORT QScrollPrepareEvent : public QEvent { public: - QScrollPrepareEvent(const QPointF &startPos); + explicit QScrollPrepareEvent(const QPointF &startPos); ~QScrollPrepareEvent(); QPointF startPos() const; -- cgit v1.2.3 From d3eb877951b4fb295e1ddc35e5ee53c782784142 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 1 Mar 2012 10:14:08 +0100 Subject: QInputMethodEvent::Attribute: mark as Q_MOVABLE_TYPE Change-Id: Ifb41afdcf17fa8192f37b4900c59e81d4e0bf60f Reviewed-by: Thiago Macieira --- src/gui/kernel/qevent.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gui') diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index feee7fa837..d70f6be201 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -464,6 +464,7 @@ private: int replace_length; QString tentativeCommit; }; +Q_DECLARE_TYPEINFO(QInputMethodEvent::Attribute, Q_MOVABLE_TYPE); class Q_GUI_EXPORT QInputMethodQueryEvent : public QEvent { -- cgit v1.2.3 From a1c75534a4bca417204725e77945e53059895726 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 24 Feb 2012 22:27:32 +0100 Subject: QtGlobal: remove qIsDetached() There's not a single in-tree user of this function, and the concept is a broken one in MT programs: By the time qIsDetached() returns, the result can already be different due to another thread taking a copy, or a copy in another thread being destroyed (note that this doesn't require mutex use by the user, since we promise (implicitly, if not explicitly) that you can copy from const objects without holding a lock). QTBUG-10813 talks about a use in QCache::trim(), but 677cf76340f88e0fe51c1f75aa512b6d835414ca removed it, so there's no reason to keep it anymore. Change-Id: I20380c12bdf00ac764b89d84392f0f34727b1971 Reviewed-by: Lars Knoll --- src/gui/image/qpixmapcache_p.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/image/qpixmapcache_p.h b/src/gui/image/qpixmapcache_p.h index 6ca109b03f..426a6d9954 100644 --- a/src/gui/image/qpixmapcache_p.h +++ b/src/gui/image/qpixmapcache_p.h @@ -96,8 +96,6 @@ public: QPixmapCache::Key key; }; -inline bool qIsDetached(QPixmapCacheEntry &t) { return t.isDetached(); } - QT_END_NAMESPACE #endif // QPIXMAPCACHE_P_H -- cgit v1.2.3