From 8249f490ff82ee2a223d2c64661cfcb1c24bdeb4 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Mon, 17 Oct 2016 14:05:10 +0200 Subject: Document QClipboard::mimeData can be null The current wording (reference) seems like it's always a pointer to valid stuff Change-Id: I2a9f8bde7d2ba672e4e664ff731a3272a6deaaaa Reviewed-by: Edward Welbourne --- src/gui/kernel/qclipboard.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp index 1aac3d6021..325ba7d787 100644 --- a/src/gui/kernel/qclipboard.cpp +++ b/src/gui/kernel/qclipboard.cpp @@ -419,8 +419,9 @@ void QClipboard::setPixmap(const QPixmap &pixmap, Mode mode) /*! \fn QMimeData *QClipboard::mimeData(Mode mode) const - Returns a reference to a QMimeData representation of the current - clipboard data. + Returns a pointer to a QMimeData representation of the current + clipboard data (can be NULL if the given \a mode is not + supported by the platform). The \a mode argument is used to control which part of the system clipboard is used. If \a mode is QClipboard::Clipboard, the -- cgit v1.2.3 From 6cfdfad7d41a7e452fa53495d9843c5d67e74946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Mon, 17 Oct 2016 23:16:15 +0100 Subject: Don't crash while parsing malformed CSS Task-Id: QTBUG-53919 Change-Id: I31a0e218e4e41ee217f8f87164f115450d69d42c Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/gui/text/qcssparser.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index 65b468ece4..e96aecdf68 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -739,8 +739,9 @@ static ColorData parseColorValue(QCss::Value v) QVector colorDigits; if (!p.parseExpr(&colorDigits)) return ColorData(); + const int tokenCount = colorDigits.count(); - for (int i = 0; i < qMin(colorDigits.count(), 7); i += 2) { + for (int i = 0; i < qMin(tokenCount, 7); i += 2) { if (colorDigits.at(i).type == Value::Percentage) { colorDigits[i].variant = colorDigits.at(i).variant.toReal() * (255. / 100.); colorDigits[i].type = Value::Number; @@ -749,11 +750,15 @@ static ColorData parseColorValue(QCss::Value v) } } + + if (tokenCount < 5) + return ColorData(); + int v1 = colorDigits.at(0).variant.toInt(); int v2 = colorDigits.at(2).variant.toInt(); int v3 = colorDigits.at(4).variant.toInt(); int alpha = 255; - if (colorDigits.count() >= 7) { + if (tokenCount >= 7) { int alphaValue = colorDigits.at(6).variant.toInt(); if (rgba && alphaValue <= 1) alpha = colorDigits.at(6).variant.toReal() * 255.; -- cgit v1.2.3 From b38145a11d03c3e3fe8baf37800a017359283861 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 12 Oct 2016 09:03:39 +0200 Subject: PDF: Handle monochrome images correctly When an image is considered to be monochrome then it should not be making the white part of the image transparent, the colors should be kept as is. Task-number: QTBUG-56489 Change-Id: I3621ca7be2a0ebe6852363f860c0b3de28d28a31 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Lars Knoll --- src/gui/painting/qpdf.cpp | 13 +++++++++---- src/gui/painting/qpdf_p.h | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src/gui') diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 0df5fd8b8a..77304fb87b 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1919,7 +1919,7 @@ int QPdfEnginePrivate::writeCompressed(const char *src, int len) } int QPdfEnginePrivate::writeImage(const QByteArray &data, int width, int height, int depth, - int maskObject, int softMaskObject, bool dct) + int maskObject, int softMaskObject, bool dct, bool isMono) { int image = addXrefEntry(-1); xprintf("<<\n" @@ -1929,8 +1929,13 @@ int QPdfEnginePrivate::writeImage(const QByteArray &data, int width, int height, "/Height %d\n", width, height); if (depth == 1) { - xprintf("/ImageMask true\n" - "/Decode [1 0]\n"); + if (!isMono) { + xprintf("/ImageMask true\n" + "/Decode [1 0]\n"); + } else { + xprintf("/BitsPerComponent 1\n" + "/ColorSpace /DeviceGray\n"); + } } else { xprintf("/BitsPerComponent 8\n" "/ColorSpace %s\n", (depth == 32) ? "/DeviceRGB" : "/DeviceGray"); @@ -2445,7 +2450,7 @@ int QPdfEnginePrivate::addImage(const QImage &img, bool *bitmap, qint64 serial_n memcpy(rawdata, image.constScanLine(y), bytesPerLine); rawdata += bytesPerLine; } - object = writeImage(data, w, h, d, 0, 0); + object = writeImage(data, w, h, d, 0, 0, false, is_monochrome(img.colorTable())); } else { QByteArray softMaskData; bool dct = false; diff --git a/src/gui/painting/qpdf_p.h b/src/gui/painting/qpdf_p.h index de30744ca2..ab7a218d89 100644 --- a/src/gui/painting/qpdf_p.h +++ b/src/gui/painting/qpdf_p.h @@ -289,7 +289,7 @@ private: int streampos; int writeImage(const QByteArray &data, int width, int height, int depth, - int maskObject, int softMaskObject, bool dct = false); + int maskObject, int softMaskObject, bool dct = false, bool isMono = false); void writePage(); int addXrefEntry(int object, bool printostr = true); -- cgit v1.2.3 From 294c870bedadc7823d61bc8df6fd37323589f0a2 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 20 Oct 2016 23:00:08 +0200 Subject: QImage: cache colortable size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Coverity threw an error that in the else branch, the expression colorTableRGB16[tableSize - 1] accesses uninit'ed data. The working theory is that it fails to perform the implication isEmpty() → size() == 0 This patch, therefore, checks for size() == 0 instead of isEmpty(), which is hardly less readable and might help Coverity understand the code better. Then again, Coverity might not understand that the tableSize can never be negative. If that's the case, another patch will be needed, but let's try the simpler solution first. Coverity-Id: 11420 Change-Id: Ibfe2a798c55af95c8001fa909aa94a6c5bc7c647 Reviewed-by: Allan Sandfeld Jensen --- src/gui/image/qimage_conversions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 7b8d88ba72..c25b4cf5c3 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -905,12 +905,12 @@ static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConvers const int dest_pad = (dst_bytes_per_line >> 1) - width; quint16 colorTableRGB16[256]; - if (data->colortable.isEmpty()) { + const int tableSize = data->colortable.size(); + if (tableSize == 0) { for (int i = 0; i < 256; ++i) colorTableRGB16[i] = qConvertRgb32To16(qRgb(i, i, i)); } else { // 1) convert the existing colors to RGB16 - const int tableSize = data->colortable.size(); for (int i = 0; i < tableSize; ++i) colorTableRGB16[i] = qConvertRgb32To16(data->colortable.at(i)); data->colortable = QVector(); -- cgit v1.2.3 From f773ddd026a6227cdb754dea4a5fe0a25137033f Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 19 Oct 2016 10:49:21 +0200 Subject: Fix when calling QSurfaceFormat::setDefaultFormat before Q*Application Fixes a regression introduced in commit 51767affb. QOpenGLContext::globalShareContext requires a QGuiApplication to exist. This wasn't required so far. Task-number: QTBUG-56614 Change-Id: I07bcf434fca536c4dc50feee7ea17eb541fd589a Reviewed-by: Liang Qi --- src/gui/kernel/qsurfaceformat.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp index 109ba8e610..d19690891f 100644 --- a/src/gui/kernel/qsurfaceformat.cpp +++ b/src/gui/kernel/qsurfaceformat.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #ifdef major #undef major @@ -760,10 +761,13 @@ Q_GLOBAL_STATIC(QSurfaceFormat, qt_default_surface_format) void QSurfaceFormat::setDefaultFormat(const QSurfaceFormat &format) { #ifndef QT_NO_OPENGL - QOpenGLContext *globalContext = QOpenGLContext::globalShareContext(); - if (globalContext && globalContext->isValid()) { - qWarning("Warning: Setting a new default format with a different version or profile after " - "the global shared context is created may cause issues with context sharing."); + if (qApp) { + QOpenGLContext *globalContext = QOpenGLContext::globalShareContext(); + if (globalContext && globalContext->isValid()) { + qWarning("Warning: Setting a new default format with a different version or profile " + "after the global shared context is created may cause issues with context " + "sharing."); + } } #endif *qt_default_surface_format() = format; -- cgit v1.2.3