diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-04-01 11:27:03 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2015-04-01 11:27:03 +0000 |
commit | 26a9783d55da551984b8c408faa837ff83df8c50 (patch) | |
tree | ad8ec0b16013fecbd6dc99bbf8999db4c6073b67 /src/gui | |
parent | f53621af053f313eff7fa7b204b5cceff675cb64 (diff) | |
parent | ce9519593a0b3deb99d1dd2529770f7e9fffef92 (diff) |
Merge "Merge remote-tracking branch 'origin/5.4' into 5.5" into refs/staging/5.5
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/image/qbmphandler.cpp | 13 | ||||
-rw-r--r-- | src/gui/image/qgifhandler.cpp | 2 | ||||
-rw-r--r-- | src/gui/image/qimage_conversions.cpp | 8 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 26 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication_p.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 9 | ||||
-rw-r--r-- | src/gui/painting/qcosmeticstroker.cpp | 20 | ||||
-rw-r--r-- | src/gui/text/qtextdocumentlayout.cpp | 2 | ||||
-rw-r--r-- | src/gui/util/qdesktopservices.cpp | 12 |
9 files changed, 59 insertions, 35 deletions
diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp index 7a491d8736..f124cede36 100644 --- a/src/gui/image/qbmphandler.cpp +++ b/src/gui/image/qbmphandler.cpp @@ -484,12 +484,6 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int p = data + (h-y-1)*bpl; break; case 2: // delta (jump) - // Protection - if ((uint)x >= (uint)w) - x = w-1; - if ((uint)y >= (uint)h) - y = h-1; - { quint8 tmp; d->getChar((char *)&tmp); @@ -497,6 +491,13 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int d->getChar((char *)&tmp); y += tmp; } + + // Protection + if ((uint)x >= (uint)w) + x = w-1; + if ((uint)y >= (uint)h) + y = h-1; + p = data + (h-y-1)*bpl + x; break; default: // absolute mode diff --git a/src/gui/image/qgifhandler.cpp b/src/gui/image/qgifhandler.cpp index 0a451e5ea3..7ba6b123e8 100644 --- a/src/gui/image/qgifhandler.cpp +++ b/src/gui/image/qgifhandler.cpp @@ -936,6 +936,8 @@ void QGIFFormat::fillRect(QImage *image, int col, int row, int w, int h, QRgb co void QGIFFormat::nextY(unsigned char *bits, int bpl) { + if (out_of_bounds) + return; int my; switch (interlace) { case 0: // Non-interlaced diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 417c185c78..28e3a48689 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -681,6 +681,8 @@ static bool convert_BGR30_to_RGB30_inplace(QImageData *data, Qt::ImageConversion static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConversionFlags) { Q_ASSERT(data->format == QImage::Format_Indexed8); + if (!data->own_data) + return false; const int depth = 32; const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; @@ -733,6 +735,8 @@ static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConve static bool convert_indexed8_to_RGB_inplace(QImageData *data, Qt::ImageConversionFlags) { Q_ASSERT(data->format == QImage::Format_Indexed8); + if (!data->own_data) + return false; const int depth = 32; const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; @@ -782,6 +786,8 @@ static bool convert_indexed8_to_RGB_inplace(QImageData *data, Qt::ImageConversio static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFlags) { Q_ASSERT(data->format == QImage::Format_Indexed8); + if (!data->own_data) + return false; const int depth = 16; const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; @@ -837,6 +843,8 @@ static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConvers static bool convert_RGB_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFlags) { Q_ASSERT(data->format == QImage::Format_RGB32); + if (!data->own_data) + return false; const int depth = 16; const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 3d21b4affc..9f73f019a3 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -236,9 +236,7 @@ struct QWindowGeometrySpecification { QWindowGeometrySpecification() : corner(Qt::TopLeftCorner), xOffset(-1), yOffset(-1), width(-1), height(-1) {} static QWindowGeometrySpecification fromArgument(const QByteArray &a); - QRect apply(const QRect &windowGeometry, const QSize &windowMinimumSize, const QSize &windowMaximumSize, const QRect &availableGeometry) const; - inline QRect apply(const QRect &windowGeometry, const QWindow *window) const - { return apply(windowGeometry, window->minimumSize(), window->maximumSize(), window->screen()->virtualGeometry()); } + void applyTo(QWindow *window) const; Qt::Corner corner; int xOffset; @@ -300,32 +298,34 @@ QWindowGeometrySpecification QWindowGeometrySpecification::fromArgument(const QB return result; } -QRect QWindowGeometrySpecification::apply(const QRect &windowGeometry, const QSize &windowMinimumSize, const QSize &windowMaximumSize, const QRect &availableGeometry) const +void QWindowGeometrySpecification::applyTo(QWindow *window) const { - QRect result = windowGeometry; + QRect windowGeometry = window->frameGeometry(); + QSize size = windowGeometry.size(); if (width >= 0 || height >= 0) { - QSize size = windowGeometry.size(); + const QSize windowMinimumSize = window->minimumSize(); + const QSize windowMaximumSize = window->maximumSize(); if (width >= 0) size.setWidth(qBound(windowMinimumSize.width(), width, windowMaximumSize.width())); if (height >= 0) size.setHeight(qBound(windowMinimumSize.height(), height, windowMaximumSize.height())); - result.setSize(size); + window->resize(size); } if (xOffset >= 0 || yOffset >= 0) { + const QRect availableGeometry = window->screen()->virtualGeometry(); QPoint topLeft = windowGeometry.topLeft(); if (xOffset >= 0) { topLeft.setX(corner == Qt::TopLeftCorner || corner == Qt::BottomLeftCorner ? xOffset : - qMax(availableGeometry.right() - result.width() - xOffset, availableGeometry.left())); + qMax(availableGeometry.right() - size.width() - xOffset, availableGeometry.left())); } if (yOffset >= 0) { topLeft.setY(corner == Qt::TopLeftCorner || corner == Qt::TopRightCorner ? yOffset : - qMax(availableGeometry.bottom() - result.height() - yOffset, availableGeometry.top())); + qMax(availableGeometry.bottom() - size.height() - yOffset, availableGeometry.top())); } - result.moveTopLeft(topLeft); + window->setFramePosition(topLeft); } - return result; } static QWindowGeometrySpecification windowGeometrySpecification; @@ -2757,9 +2757,9 @@ void QGuiApplication::setPalette(const QPalette &pal) emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); } -QRect QGuiApplicationPrivate::applyWindowGeometrySpecification(const QRect &windowGeometry, const QWindow *window) +void QGuiApplicationPrivate::applyWindowGeometrySpecificationTo(QWindow *window) { - return windowGeometrySpecification.apply(windowGeometry, window); + windowGeometrySpecification.applyTo(window); } /*! diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 7ae6e64b26..0559442049 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -279,7 +279,7 @@ public: virtual void notifyWindowIconChanged(); - static QRect applyWindowGeometrySpecification(const QRect &windowGeometry, const QWindow *window); + static void applyWindowGeometrySpecificationTo(QWindow *window); static void setApplicationState(Qt::ApplicationState state, bool forcePropagate = false); diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 06674d204d..c0f953bcef 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -489,6 +489,13 @@ void QWindow::setVisible(bool visible) } if (!app_priv->forcedWindowIcon.isNull()) setIcon(app_priv->forcedWindowIcon); + + // Handling of the -qwindowgeometry, -geometry command line arguments + static bool geometryApplied = false; + if (!geometryApplied) { + geometryApplied = true; + QGuiApplicationPrivate::applyWindowGeometrySpecificationTo(this); + } } QShowEvent showEvent; @@ -1502,10 +1509,10 @@ void QWindow::setFramePosition(const QPoint &point) { Q_D(QWindow); d->positionPolicy = QWindowPrivate::WindowFrameInclusive; + d->positionAutomatic = false; if (d->platformWindow) { d->platformWindow->setGeometry(QRect(point, size())); } else { - d->positionAutomatic = false; d->geometry.moveTopLeft(point); } } diff --git a/src/gui/painting/qcosmeticstroker.cpp b/src/gui/painting/qcosmeticstroker.cpp index f82b098012..8fb5f4fd3f 100644 --- a/src/gui/painting/qcosmeticstroker.cpp +++ b/src/gui/painting/qcosmeticstroker.cpp @@ -602,8 +602,7 @@ void QCosmeticStroker::drawPath(const QVectorPath &path) if (!closed && drawCaps && points == end - 2) caps |= CapEnd; - QCosmeticStroker::Point last = this->lastPixel; - bool unclipped = stroke(this, p.x(), p.y(), p2.x(), p2.y(), caps); + bool moveNextStart = stroke(this, p.x(), p.y(), p2.x(), p2.y(), caps); /* fix for gaps in polylines with fastpen and aliased in a sequence of points with small distances: if current point p2 has been dropped @@ -613,14 +612,8 @@ void QCosmeticStroker::drawPath(const QVectorPath &path) still need to update p to avoid drawing the line after this one from a bad starting position. */ - if (fastPenAliased && unclipped) { - if (last.x != lastPixel.x || last.y != lastPixel.y - || points == begin + 2 || points == end - 2) { - p = p2; - } - } else { + if (!fastPenAliased || moveNextStart || points == begin + 2 || points == end - 2) p = p2; - } points += 2; caps = NoCaps; } @@ -727,8 +720,9 @@ template<DrawPixel drawPixel, class Dasher> static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, qreal ry2, int caps) { if (stroker->clipLine(rx1, ry1, rx2, ry2)) - return false; + return true; + bool didDraw = false; const int half = stroker->legacyRounding ? 31 : 0; int x1 = toF26Dot6(rx1) + half; int y1 = toF26Dot6(ry1) + half; @@ -814,6 +808,7 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, dasher.adjust(); x += xinc; } while (++y < ys); + didDraw = true; } } else { // horizontal @@ -889,10 +884,11 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, dasher.adjust(); y += yinc; } while (++x < xs); + didDraw = true; } } stroker->lastPixel = last; - return true; + return didDraw; } @@ -900,7 +896,7 @@ template<DrawPixel drawPixel, class Dasher> static bool drawLineAA(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, qreal ry2, int caps) { if (stroker->clipLine(rx1, ry1, rx2, ry2)) - return false; + return true; int x1 = toF26Dot6(rx1); int y1 = toF26Dot6(ry1); diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index 3a86a454ac..db8a792be7 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -2432,7 +2432,7 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayout ++it; } else { QTextFrame::Iterator lastIt; - if (!previousIt.atEnd()) + if (!previousIt.atEnd() && previousIt != it) lastIt = previousIt; previousIt = it; QTextBlock block = it.currentBlock(); diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp index 385706f09e..4c92e5d000 100644 --- a/src/gui/util/qdesktopservices.cpp +++ b/src/gui/util/qdesktopservices.cpp @@ -166,6 +166,11 @@ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler) Unicode-aware, the user may have configured their client without these features. Also, certain e-mail clients (e.g., Lotus Notes) have problems with long URLs. + \warning A return value of \c true indicates that the application has successfully requested + the operating system to open the URL in an external application. The external application may + still fail to launch or fail to open the requested URL. This result will not be reported back + to the application. + \sa setUrlHandler() */ bool QDesktopServices::openUrl(const QUrl &url) @@ -185,7 +190,12 @@ bool QDesktopServices::openUrl(const QUrl &url) } if (!url.isValid()) return false; - QPlatformServices *platformServices = QGuiApplicationPrivate::platformIntegration()->services(); + + QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration(); + if (!platformIntegration) + return false; + + QPlatformServices *platformServices = platformIntegration->services(); if (!platformServices) { qWarning("%s: The platform plugin does not support services.", Q_FUNC_INFO); return false; |