summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qkeysequence.cpp2
-rw-r--r--src/gui/kernel/qkeysequence_p.h3
-rw-r--r--src/gui/painting/qpainter.cpp12
-rw-r--r--src/gui/painting/qpdf.cpp2
-rw-r--r--src/gui/text/qzip.cpp9
5 files changed, 15 insertions, 13 deletions
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index 8a6eeb4cc9..8ccd85795b 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -1643,7 +1643,7 @@ QDataStream &operator>>(QDataStream &s, QKeySequence &keysequence)
s >> keys[i];
}
qAtomicDetach(keysequence.d);
- std::copy(keys, keys + MaxKeys, keysequence.d->key);
+ std::copy(keys, keys + MaxKeys, QT_MAKE_CHECKED_ARRAY_ITERATOR(keysequence.d->key, MaxKeys));
return s;
}
diff --git a/src/gui/kernel/qkeysequence_p.h b/src/gui/kernel/qkeysequence_p.h
index eeea0f5772..116e91c0cd 100644
--- a/src/gui/kernel/qkeysequence_p.h
+++ b/src/gui/kernel/qkeysequence_p.h
@@ -76,7 +76,8 @@ public:
}
inline QKeySequencePrivate(const QKeySequencePrivate &copy) : ref(1)
{
- std::copy(copy.key, copy.key + MaxKeyCount, key);
+ std::copy(copy.key, copy.key + MaxKeyCount,
+ QT_MAKE_CHECKED_ARRAY_ITERATOR(key, MaxKeyCount));
}
QAtomicInt ref;
int key[MaxKeyCount];
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index bcef14ca61..0b205b8b0e 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -6183,7 +6183,8 @@ static QPixmap generateWavyPixmap(qreal maxRadius, const QPen &pen)
QString key = QLatin1String("WaveUnderline-")
% pen.color().name()
- % HexString<qreal>(radiusBase);
+ % HexString<qreal>(radiusBase)
+ % HexString<qreal>(pen.widthF());
QPixmap pixmap;
if (QPixmapCache::find(key, pixmap))
@@ -6191,7 +6192,7 @@ static QPixmap generateWavyPixmap(qreal maxRadius, const QPen &pen)
const qreal halfPeriod = qMax(qreal(2), qreal(radiusBase * 1.61803399)); // the golden ratio
const int width = qCeil(100 / (2 * halfPeriod)) * (2 * halfPeriod);
- const int radius = qFloor(radiusBase);
+ const qreal radius = qFloor(radiusBase * 2) / 2.;
QPainterPath path;
@@ -6214,7 +6215,7 @@ static QPixmap generateWavyPixmap(qreal maxRadius, const QPen &pen)
// due to it having a rather thick width for the regular underline.
const qreal maxPenWidth = .8 * radius;
if (wavePen.widthF() > maxPenWidth)
- wavePen.setWidth(maxPenWidth);
+ wavePen.setWidthF(maxPenWidth);
QPainter imgPainter(&pixmap);
imgPainter.setPen(wavePen);
@@ -6267,14 +6268,15 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const
if (underlineStyle == QTextCharFormat::WaveUnderline) {
painter->save();
painter->translate(0, pos.y() + 1);
+ qreal maxHeight = fe->descent().toReal() - qreal(1);
QColor uc = charFormat.underlineColor();
if (uc.isValid())
pen.setColor(uc);
// Adapt wave to underlineOffset or pen width, whatever is larger, to make it work on all platforms
- const QPixmap wave = generateWavyPixmap(qMax(underlineOffset, pen.widthF()), pen);
- const int descent = (int) fe->descent().toReal();
+ const QPixmap wave = generateWavyPixmap(qMin(qMax(underlineOffset, pen.widthF()), maxHeight / 2.), pen);
+ const int descent = qFloor(maxHeight);
painter->setBrushOrigin(painter->brushOrigin().x(), 0);
painter->fillRect(pos.x(), 0, qCeil(width), qMin(wave.height(), descent), wave);
diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp
index 8189351bd8..9e38c5272f 100644
--- a/src/gui/painting/qpdf.cpp
+++ b/src/gui/painting/qpdf.cpp
@@ -1202,7 +1202,7 @@ void QPdfEngine::setPen()
switch(d->pen.joinStyle()) {
case Qt::MiterJoin:
case Qt::SvgMiterJoin:
- *d->currentPage << d->pen.miterLimit() << "M ";
+ *d->currentPage << qMax(qreal(1.0), d->pen.miterLimit()) << "M ";
pdfJoinStyle = 0;
break;
case Qt::BevelJoin:
diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp
index 5178f5a9a8..7cb89543ba 100644
--- a/src/gui/text/qzip.cpp
+++ b/src/gui/text/qzip.cpp
@@ -822,12 +822,12 @@ void QZipWriterPrivate::addEntry(EntryType type, const QString &fileName, const
QZipReader::QZipReader(const QString &archive, QIODevice::OpenMode mode)
{
QScopedPointer<QFile> f(new QFile(archive));
- f->open(mode);
+ const bool result = f->open(mode);
QZipReader::Status status;
const QFileDevice::FileError error = f->error();
- if (error == QFile::NoError)
+ if (result && error == QFile::NoError) {
status = NoError;
- else {
+ } else {
if (error == QFile::ReadError)
status = FileReadError;
else if (error == QFile::OpenError)
@@ -1119,9 +1119,8 @@ void QZipReader::close()
QZipWriter::QZipWriter(const QString &fileName, QIODevice::OpenMode mode)
{
QScopedPointer<QFile> f(new QFile(fileName));
- f->open(mode);
QZipWriter::Status status;
- if (f->error() == QFile::NoError)
+ if (f->open(mode) && f->error() == QFile::NoError)
status = QZipWriter::NoError;
else {
if (f->error() == QFile::WriteError)