From ff35fc61cc8d6b103da4f079fce170d82406cea0 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Wed, 2 Jun 2010 09:21:35 +0200 Subject: Doc: Removed a link to Qt3 support in QSlider Task-number: QTBUG-6394 --- src/gui/widgets/qslider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qslider.cpp b/src/gui/widgets/qslider.cpp index a5e62cf..5755202 100644 --- a/src/gui/widgets/qslider.cpp +++ b/src/gui/widgets/qslider.cpp @@ -621,7 +621,7 @@ QSlider::TickPosition QSlider::tickPosition() const \brief the interval between tickmarks This is a value interval, not a pixel interval. If it is 0, the - slider will choose between lineStep() and pageStep(). + slider will choose between singleStep() and pageStep(). The default value is 0. -- cgit v0.12 From af8b034e2886ecb11db51d4fecc29177595b86ab Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Fri, 4 Jun 2010 13:50:36 +0200 Subject: Doc: QTreeWidgetItems remove themselves from views when deleted. Task-number: QTBUG-10640 --- src/gui/itemviews/qtreewidget.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/itemviews/qtreewidget.cpp b/src/gui/itemviews/qtreewidget.cpp index 0e06f34..8f55734 100644 --- a/src/gui/itemviews/qtreewidget.cpp +++ b/src/gui/itemviews/qtreewidget.cpp @@ -1472,6 +1472,10 @@ QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem *parent, QTreeWidgetItem *after /*! Destroys this tree widget item. + + The item will be removed from \l{QTreeWidget}s to which it has + been added. This makes it safe to delete an item at any time. + */ QTreeWidgetItem::~QTreeWidgetItem() -- cgit v0.12 From 7ffb1c2e821cc4d508dcedcdb7363756f9f693ff Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Fri, 4 Jun 2010 15:06:45 +0200 Subject: Doc: Said to not access events after they are posted(postEvent). Task-number: QTBUG-10210 --- src/corelib/kernel/qcoreapplication.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 4e6e6b9..0a5e06e 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -1073,7 +1073,7 @@ void QCoreApplication::exit(int returnCode) The event must be allocated on the heap since the post event queue will take ownership of the event and delete it once it has been - posted. It is \e {not safe} to modify or delete the event after + posted. It is \e {not safe} to access the event after it has been posted. When control returns to the main event loop, all events that are @@ -1104,7 +1104,7 @@ void QCoreApplication::postEvent(QObject *receiver, QEvent *event) The event must be allocated on the heap since the post event queue will take ownership of the event and delete it once it has been - posted. It is \e {not safe} to modify or delete the event after + posted. It is \e {not safe} to access the event after it has been posted. When control returns to the main event loop, all events that are -- cgit v0.12 From d6bcab9e1cfb3a3b91b45269d68a594f6f079914 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 15 Jun 2010 10:14:18 +0200 Subject: Fix regression, remove artificial emboldening of monospaced fonts In change 889e13652e00ba64060e7b62ed3377ea04d44faa we employed usage of artificial emboldening of fonts with FreeType when a bold variant of the font does not exist. This introduced a regression for monospaced fonts, where the contract says that all glyphs must be the same width. Since the artificial emboldening algorithm does not support this contract, it has been turned off for monospaced fonts, reverting to the old behavior for this particular class of fonts. Task-number: QTBUG-11353 Reviewed-by: Paul --- src/gui/text/qfontengine_ft.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 9056012..2c4fbab 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -690,7 +690,7 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format) if (fake_oblique) transform = true; // fake bold - if ((fontDef.weight == QFont::Bold) && !(face->style_flags & FT_STYLE_FLAG_BOLD)) + if ((fontDef.weight == QFont::Bold) && !(face->style_flags & FT_STYLE_FLAG_BOLD) && !FT_IS_FIXED_WIDTH(face)) embolden = true; // underline metrics line_thickness = QFixed::fromFixed(FT_MulFix(face->underline_thickness, face->size->metrics.y_scale)); -- cgit v0.12 From a041e4eca3467c1baa6245b6fb47def127f30f41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 15 Jun 2010 10:45:23 +0200 Subject: Added missing sanity checks in qimage.cpp We should be consistent and do sanity checks whenever we allocate new images. Task-number: QTBUG-1985 Reviewed-by: Eskil --- src/gui/image/qimage.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index d89ffe6..adc2632 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -4210,6 +4210,7 @@ QImage QImage::createHeuristicMask(bool clipTight) const int w = width(); int h = height(); QImage m(w, h, Format_MonoLSB); + QIMAGE_SANITYCHECK_MEMORY(m); m.setColorCount(2); m.setColor(0, QColor(Qt::color0).rgba()); m.setColor(1, QColor(Qt::color1).rgba()); @@ -4302,6 +4303,7 @@ QImage QImage::createMaskFromColor(QRgb color, Qt::MaskMode mode) const if (!d) return QImage(); QImage maskImage(size(), QImage::Format_MonoLSB); + QIMAGE_SANITYCHECK_MEMORY(maskImage); maskImage.fill(0); uchar *s = maskImage.bits(); @@ -4362,6 +4364,7 @@ QImage QImage::mirrored(bool horizontal, bool vertical) const int h = d->height; // Create result image, copy colormap QImage result(d->width, d->height, d->format); + QIMAGE_SANITYCHECK_MEMORY(result); // check if we ran out of of memory.. if (!result.d) @@ -4499,6 +4502,7 @@ QImage QImage::rgbSwapped() const case Format_ARGB32: case Format_ARGB32_Premultiplied: res = QImage(d->width, d->height, d->format); + QIMAGE_SANITYCHECK_MEMORY(res); for (int i = 0; i < d->height; i++) { uint *q = (uint*)res.scanLine(i); uint *p = (uint*)scanLine(i); @@ -4512,6 +4516,7 @@ QImage QImage::rgbSwapped() const break; case Format_RGB16: res = QImage(d->width, d->height, d->format); + QIMAGE_SANITYCHECK_MEMORY(res); for (int i = 0; i < d->height; i++) { ushort *q = (ushort*)res.scanLine(i); const ushort *p = (const ushort*)scanLine(i); @@ -4525,6 +4530,7 @@ QImage QImage::rgbSwapped() const break; case Format_ARGB8565_Premultiplied: res = QImage(d->width, d->height, d->format); + QIMAGE_SANITYCHECK_MEMORY(res); for (int i = 0; i < d->height; i++) { quint8 *p = (quint8*)scanLine(i); const quint8 *end = p + d->width * sizeof(qargb8565); @@ -4537,6 +4543,7 @@ QImage QImage::rgbSwapped() const break; case Format_RGB666: res = QImage(d->width, d->height, d->format); + QIMAGE_SANITYCHECK_MEMORY(res); for (int i = 0; i < d->height; i++) { qrgb666 *q = reinterpret_cast(res.scanLine(i)); const qrgb666 *p = reinterpret_cast(scanLine(i)); @@ -4549,6 +4556,7 @@ QImage QImage::rgbSwapped() const break; case Format_ARGB6666_Premultiplied: res = QImage(d->width, d->height, d->format); + QIMAGE_SANITYCHECK_MEMORY(res); for (int i = 0; i < d->height; i++) { qargb6666 *q = reinterpret_cast(res.scanLine(i)); const qargb6666 *p = reinterpret_cast(scanLine(i)); @@ -4561,6 +4569,7 @@ QImage QImage::rgbSwapped() const break; case Format_RGB555: res = QImage(d->width, d->height, d->format); + QIMAGE_SANITYCHECK_MEMORY(res); for (int i = 0; i < d->height; i++) { ushort *q = (ushort*)res.scanLine(i); const ushort *p = (const ushort*)scanLine(i); @@ -4574,6 +4583,7 @@ QImage QImage::rgbSwapped() const break; case Format_ARGB8555_Premultiplied: res = QImage(d->width, d->height, d->format); + QIMAGE_SANITYCHECK_MEMORY(res); for (int i = 0; i < d->height; i++) { quint8 *p = (quint8*)scanLine(i); const quint8 *end = p + d->width * sizeof(qargb8555); @@ -4586,6 +4596,7 @@ QImage QImage::rgbSwapped() const break; case Format_RGB888: res = QImage(d->width, d->height, d->format); + QIMAGE_SANITYCHECK_MEMORY(res); for (int i = 0; i < d->height; i++) { quint8 *q = reinterpret_cast(res.scanLine(i)); const quint8 *p = reinterpret_cast(scanLine(i)); @@ -4601,6 +4612,7 @@ QImage QImage::rgbSwapped() const break; case Format_RGB444: res = QImage(d->width, d->height, d->format); + QIMAGE_SANITYCHECK_MEMORY(res); for (int i = 0; i < d->height; i++) { quint8 *q = reinterpret_cast(res.scanLine(i)); const quint8 *p = reinterpret_cast(scanLine(i)); @@ -4615,6 +4627,7 @@ QImage QImage::rgbSwapped() const break; case Format_ARGB4444_Premultiplied: res = QImage(d->width, d->height, d->format); + QIMAGE_SANITYCHECK_MEMORY(res); for (int i = 0; i < d->height; i++) { quint8 *q = reinterpret_cast(res.scanLine(i)); const quint8 *p = reinterpret_cast(scanLine(i)); -- cgit v0.12 From c5b06919a8fb5d20aae41f0edf9e2ffa99eb1a8a Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Tue, 15 Jun 2010 13:59:41 +0200 Subject: Doc: Documented qputenv and qgetenv Task-number: QTBUG-4041 Reviewed-by: Morten Engvoldsen --- src/corelib/global/qglobal.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 373c0b4..b31c83b 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2503,6 +2503,19 @@ void qFatal(const char *msg, ...) // getenv is declared as deprecated in VS2005. This function // makes use of the new secure getenv function. +/*! + \relates + + Returns the value of the environment variable with name \a + varName. To get the variable string, use QByteArray::constData(). + + \note qgetenv() was introduced because getenv() from the standard + C library was deprecated in VC2005 (and later versions). qgetenv() + uses the new replacement function in VC, and calls the standard C + library's implementation on all other platforms. + + \sa qputenv() +*/ QByteArray qgetenv(const char *varName) { #if defined(_MSC_VER) && _MSC_VER >= 1400 @@ -2522,6 +2535,20 @@ QByteArray qgetenv(const char *varName) #endif } +/*! + \relates + + This function sets the \a value of the environment variable named + \a varName. It will create the variable if it does not exist. It + returns 0 if the variable could not be set. + + \note qputenv() was introduced because putenv() from the standard + C library was deprecated in VC2005 (and later versions). qputenv() + uses the replacement function in VC, and calls the standard C + library's implementation on all other platforms. + + \sa qgetenv() +*/ bool qputenv(const char *varName, const QByteArray& value) { #if defined(_MSC_VER) && _MSC_VER >= 1400 -- cgit v0.12 From c28efecdcfdd5fa0049bf482cb102814338c0d99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 15 Jun 2010 12:33:39 +0200 Subject: Fixed missing stroke for flat ellipses. The behavior should be the same as for arcs and rects. Task-number: QTBUG-2743 Reviewed-by: Eskil --- src/gui/painting/qpaintengine_raster.cpp | 1 + src/gui/painting/qpaintengine_x11.cpp | 5 +++++ src/gui/painting/qpainter.cpp | 4 ---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 9f1128b..f10f12f 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -3789,6 +3789,7 @@ void QRasterPaintEngine::drawEllipse(const QRectF &rect) if (((qpen_style(s->lastPen) == Qt::SolidLine && s->flags.fast_pen) || (qpen_style(s->lastPen) == Qt::NoPen && !s->flags.antialiased)) && qMax(rect.width(), rect.height()) < QT_RASTER_COORD_LIMIT + && !rect.isEmpty() && s->matrix.type() <= QTransform::TxScale) // no shear { ensureBrush(); diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp index b8ad9b3..910b2df 100644 --- a/src/gui/painting/qpaintengine_x11.cpp +++ b/src/gui/painting/qpaintengine_x11.cpp @@ -1453,6 +1453,11 @@ void QX11PaintEngine::drawEllipse(const QRectF &rect) void QX11PaintEngine::drawEllipse(const QRect &rect) { + if (rect.isEmpty()) { + drawRects(&rect, 1); + return; + } + Q_D(QX11PaintEngine); QRect devclip(SHRT_MIN, SHRT_MIN, SHRT_MAX*2 - 1, SHRT_MAX*2 - 1); QRect r(rect); diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index e8c4599..d17c711 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -4238,8 +4238,6 @@ void QPainter::drawEllipse(const QRectF &r) return; QRectF rect(r.normalized()); - if (rect.isEmpty()) - return; if (d->extended) { d->extended->drawEllipse(rect); @@ -4281,8 +4279,6 @@ void QPainter::drawEllipse(const QRect &r) return; QRect rect(r.normalized()); - if (rect.isEmpty()) - return; if (d->extended) { d->extended->drawEllipse(rect); -- cgit v0.12 From df55141aa260c8a10c06aa990b6f20d6fb4718f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 15 Jun 2010 13:06:19 +0200 Subject: Fixed QImageReader::format() inconsistency. If state is set to ReadHeader before canRead() then setFormat("png") never gets called. We should make sure that setFormat() gets set whenever canRead() returns true. Task-number: QTBUG-2263 Reviewed-by: Kent Hansen --- src/gui/image/qbmphandler.cpp | 10 +++++---- src/gui/image/qpnghandler.cpp | 10 +++++---- src/gui/image/qppmhandler.cpp | 10 +++++---- src/gui/image/qxbmhandler.cpp | 10 +++++---- src/gui/image/qxpmhandler.cpp | 8 ++++++-- src/plugins/imageformats/gif/qgifhandler.cpp | 4 ++-- src/plugins/imageformats/jpeg/qjpeghandler.cpp | 10 +++++---- src/plugins/imageformats/mng/qmnghandler.cpp | 8 ++++---- tests/auto/qimagereader/tst_qimagereader.cpp | 28 ++++++++++++++++++++++++++ 9 files changed, 70 insertions(+), 28 deletions(-) diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp index 42e19b8..074b8f0 100644 --- a/src/gui/image/qbmphandler.cpp +++ b/src/gui/image/qbmphandler.cpp @@ -674,13 +674,15 @@ bool QBmpHandler::readHeader() bool QBmpHandler::canRead() const { - if (state == Ready) { - if (!canRead(device())) - return false; + if (state == Ready && !canRead(device())) + return false; + + if (state != Error) { setFormat("bmp"); return true; } - return state != Error; + + return false; } bool QBmpHandler::canRead(QIODevice *device) diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index dd31834..2cf8222 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -892,13 +892,15 @@ QPngHandler::~QPngHandler() bool QPngHandler::canRead() const { - if (d->state == QPngHandlerPrivate::Ready) { - if (!canRead(device())) - return false; + if (d->state == QPngHandlerPrivate::Ready && !canRead(device())) + return false; + + if (d->state != QPngHandlerPrivate::Error) { setFormat("png"); return true; } - return d->state != QPngHandlerPrivate::Error; + + return false; } bool QPngHandler::canRead(QIODevice *device) diff --git a/src/gui/image/qppmhandler.cpp b/src/gui/image/qppmhandler.cpp index cbbbef4..a9e796c 100644 --- a/src/gui/image/qppmhandler.cpp +++ b/src/gui/image/qppmhandler.cpp @@ -409,13 +409,15 @@ bool QPpmHandler::readHeader() bool QPpmHandler::canRead() const { - if (state == Ready) { - if (!canRead(device(), &subType)) - return false; + if (state == Ready && !canRead(device(), &subType)) + return false; + + if (state != Error) { setFormat(subType); return true; } - return state != Error; + + return false; } bool QPpmHandler::canRead(QIODevice *device, QByteArray *subType) diff --git a/src/gui/image/qxbmhandler.cpp b/src/gui/image/qxbmhandler.cpp index 385340a..0dd4e99 100644 --- a/src/gui/image/qxbmhandler.cpp +++ b/src/gui/image/qxbmhandler.cpp @@ -261,13 +261,15 @@ bool QXbmHandler::readHeader() bool QXbmHandler::canRead() const { - if (state == Ready) { - if (!canRead(device())) - return false; + if (state == Ready && !canRead(device())) + return false; + + if (state != Error) { setFormat("xbm"); return true; } - return state != Error; + + return false; } bool QXbmHandler::canRead(QIODevice *device) diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index a475cd0..b97afd3 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -1225,11 +1225,15 @@ bool QXpmHandler::readImage(QImage *image) bool QXpmHandler::canRead() const { - if (state == Ready && canRead(device())) { + if (state == Ready && !canRead(device())) + return false; + + if (state != Error) { setFormat("xpm"); return true; } - return state != Error; + + return false; } bool QXpmHandler::canRead(QIODevice *device) diff --git a/src/plugins/imageformats/gif/qgifhandler.cpp b/src/plugins/imageformats/gif/qgifhandler.cpp index 8abc2d1..5e2157e 100644 --- a/src/plugins/imageformats/gif/qgifhandler.cpp +++ b/src/plugins/imageformats/gif/qgifhandler.cpp @@ -1061,12 +1061,12 @@ bool QGifHandler::imageIsComing() const bool QGifHandler::canRead() const { - if (!nextDelay && canRead(device())) { + if (!nextDelay && canRead(device()) || imageIsComing()) { setFormat("gif"); return true; } - return imageIsComing(); + return false; } bool QGifHandler::canRead(QIODevice *device) diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp index 72dde15..60e7cce 100644 --- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp +++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp @@ -802,13 +802,15 @@ QJpegHandler::~QJpegHandler() bool QJpegHandler::canRead() const { - if(d->state == QJpegHandlerPrivate::Ready) { - if (!canRead(device())) - return false; + if(d->state == QJpegHandlerPrivate::Ready && !canRead(device())) + return false; + + if (d->state != QJpegHandlerPrivate::Error) { setFormat("jpeg"); return true; } - return d->state != QJpegHandlerPrivate::Error; + + return false; } bool QJpegHandler::canRead(QIODevice *device) diff --git a/src/plugins/imageformats/mng/qmnghandler.cpp b/src/plugins/imageformats/mng/qmnghandler.cpp index d408e6c..c134fd6 100644 --- a/src/plugins/imageformats/mng/qmnghandler.cpp +++ b/src/plugins/imageformats/mng/qmnghandler.cpp @@ -381,10 +381,10 @@ QMngHandler::~QMngHandler() bool QMngHandler::canRead() const { Q_D(const QMngHandler); - if (!d->haveReadNone) - return (!d->haveReadAll || (d->haveReadAll && (d->nextIndex < d->frameCount))); - - if (canRead(device())) { + if ((!d->haveReadNone + && (!d->haveReadAll || (d->haveReadAll && (d->nextIndex < d->frameCount)))) + || canRead(device())) + { setFormat("mng"); return true; } diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index aadee5b..7e57973 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -138,6 +138,9 @@ private slots: void sizeBeforeRead_data(); void sizeBeforeRead(); + void sizeBeforeFormat_data(); + void sizeBeforeFormat(); + void imageFormatBeforeRead_data(); void imageFormatBeforeRead(); @@ -706,6 +709,31 @@ void tst_QImageReader::sizeBeforeRead() QCOMPARE(size, image.size()); } +void tst_QImageReader::sizeBeforeFormat_data() +{ + imageFormat_data(); +} + +void tst_QImageReader::sizeBeforeFormat() +{ + QFETCH(QString, fileName); + + QByteArray formatA, formatB; + + { + QImageReader reader(prefix + fileName); + formatA = reader.format(); + } + + { + QImageReader reader(prefix + fileName); + QSize size = reader.size(); + formatB = reader.format(); + } + + QCOMPARE(formatA, formatB); +} + void tst_QImageReader::imageFormatBeforeRead_data() { imageFormat_data(); -- cgit v0.12