summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-10-17 17:48:34 +0200
committerMarc Mutz <marc.mutz@kdab.com>2016-03-04 10:29:08 +0000
commit600529e07a46d8e20f4302dc988125f3fee36ec4 (patch)
treed1ef58c493d6f9dd2521c63ce1f07e04a7aa5658 /src/gui/text
parentb6b3803b213787a04dfc7542caeb541a5535d90f (diff)
QtGui: use printf-style qWarning/qDebug where possible (I)
The printf-style version of QDebug expands to a lot less code than the std::ostream-style version. Of course, you pay in type safety (but compilers warn about it these days), you cannot stream complex Qt types and streaming QStrings is awkward, but in many cases you actually improve on readability. But the main reason is that something that's not supposed to be executed under normal operation has no business bloating executable code size. This is not an attempt at converting all qWarnings() to printf-style, only the low-hanging fruit. In this first part, replace qWarning() << "..."; with qWarning("..."); In QTransform shared warning strings. Saves 3KiB in text size on optimized GCC 5.3 AMD64 builds. Change-Id: I142a8020eaab043d78465178192f2c8c6d1cc4f9 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qfontengine_qpf2.cpp2
-rw-r--r--src/gui/text/qfontsubset.cpp6
-rw-r--r--src/gui/text/qplatformfontdatabase.cpp2
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp6
-rw-r--r--src/gui/text/qtextdocumentwriter.cpp4
-rw-r--r--src/gui/text/qtextengine.cpp2
-rw-r--r--src/gui/text/qtextlayout.cpp2
-rw-r--r--src/gui/text/qtextodfwriter.cpp2
-rw-r--r--src/gui/text/qzip.cpp16
9 files changed, 21 insertions, 21 deletions
diff --git a/src/gui/text/qfontengine_qpf2.cpp b/src/gui/text/qfontengine_qpf2.cpp
index 4b5d241e60..c3a911fc55 100644
--- a/src/gui/text/qfontengine_qpf2.cpp
+++ b/src/gui/text/qfontengine_qpf2.cpp
@@ -246,7 +246,7 @@ QFontEngineQPF2::QFontEngineQPF2(const QFontDef &def, const QByteArray &data)
if (!verifyHeader(fontData, dataSize)) {
#if defined(DEBUG_FONTENGINE)
- qDebug() << "verifyHeader failed!";
+ qDebug("verifyHeader failed!");
#endif
return;
}
diff --git a/src/gui/text/qfontsubset.cpp b/src/gui/text/qfontsubset.cpp
index a9387e5aa0..f591b4333c 100644
--- a/src/gui/text/qfontsubset.cpp
+++ b/src/gui/text/qfontsubset.cpp
@@ -798,7 +798,7 @@ static void convertPath(const QPainterPath &path, QVector<TTF_POINT> *points, QV
base -= 3;
} else {
// need to split
-// qDebug() << " -> splitting";
+// qDebug(" -> splitting");
qint16 a, b, c, d;
base[6].x = base[3].x;
c = base[1].x;
@@ -859,7 +859,7 @@ static void getBounds(const QVector<TTF_POINT> &points, qint16 *xmin, qint16 *xm
static int convertToRelative(QVector<TTF_POINT> *points)
{
// convert points to relative and setup flags
-// qDebug() << "relative points:";
+// qDebug("relative points:");
qint16 prev_x = 0;
qint16 prev_y = 0;
int point_array_size = 0;
@@ -980,7 +980,7 @@ static QTtfGlyph generateGlyph(int index, const QPainterPath &path, qreal advanc
// qDebug() << "number of contours=" << endPoints.size();
// for (int i = 0; i < points.size(); ++i)
// qDebug() << " point[" << i << "] = " << QPoint(points.at(i).x, points.at(i).y) << " flags=" << points.at(i).flags;
-// qDebug() << "endPoints:";
+// qDebug("endPoints:");
// for (int i = 0; i < endPoints.size(); ++i)
// qDebug() << endPoints.at(i);
diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp
index 017e2f254d..0d7cb204ff 100644
--- a/src/gui/text/qplatformfontdatabase.cpp
+++ b/src/gui/text/qplatformfontdatabase.cpp
@@ -100,7 +100,7 @@ void QPlatformFontDatabase::registerQPF2Font(const QByteArray &dataArray, void *
registerFont(fontName,QString(),QString(),fontWeight,fontStyle,stretch,true,false,pixelSize,false,writingSystems,handle);
}
} else {
- qDebug() << "header verification of QPF2 font failed. maybe it is corrupt?";
+ qDebug("header verification of QPF2 font failed. maybe it is corrupt?");
}
}
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index ff492b15f6..c26fd08c41 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -1598,7 +1598,7 @@ QTextLayoutStruct QTextDocumentLayoutPrivate::layoutCell(QTextTable *t, const QT
// floats in other cells we must clear the list here.
data(t)->floats.clear();
-// qDebug() << "layoutCell done";
+// qDebug("layoutCell done");
return layoutStruct;
}
@@ -2030,7 +2030,7 @@ void QTextDocumentLayoutPrivate::positionFloat(QTextFrame *frame, QTextLine *cur
// qDebug() << "have line: right=" << right << "left=" << left << "textWidth=" << currentLine->width();
if (right - left < QFixed::fromReal(currentLine->naturalTextWidth()) + fd->size.width) {
layoutStruct->pendingFloats.append(frame);
-// qDebug() << " adding to pending list";
+// qDebug(" adding to pending list");
return;
}
}
@@ -2543,7 +2543,7 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayout
contentHasAlignment = true;
if (it.atEnd()) {
- //qDebug() << "layout done!";
+ //qDebug("layout done!");
currentLazyLayoutPosition = -1;
QCheckPoint cp;
cp.y = layoutStruct->y;
diff --git a/src/gui/text/qtextdocumentwriter.cpp b/src/gui/text/qtextdocumentwriter.cpp
index d672b1187a..a7c58ac2a6 100644
--- a/src/gui/text/qtextdocumentwriter.cpp
+++ b/src/gui/text/qtextdocumentwriter.cpp
@@ -271,7 +271,7 @@ bool QTextDocumentWriter::write(const QTextDocument *document)
#ifndef QT_NO_TEXTHTMLPARSER
if (format == "html" || format == "htm") {
if (!d->device->isWritable() && ! d->device->open(QIODevice::WriteOnly)) {
- qWarning() << "QTextDocumentWriter::write: the device can not be opened for writing";
+ qWarning("QTextDocumentWriter::write: the device can not be opened for writing");
return false;
}
QTextStream ts(d->device);
@@ -285,7 +285,7 @@ bool QTextDocumentWriter::write(const QTextDocument *document)
#endif
if (format == "txt" || format == "plaintext") {
if (!d->device->isWritable() && ! d->device->open(QIODevice::WriteOnly)) {
- qWarning() << "QTextDocumentWriter::write: the device can not be opened for writing";
+ qWarning("QTextDocumentWriter::write: the device can not be opened for writing");
return false;
}
QTextStream ts(d->device);
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index f5df6fd60b..3ee6177f3c 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -816,7 +816,7 @@ void QTextEngine::bidiReorder(int numItems, const quint8 *levels, int *visualOrd
}
#if (BIDI_DEBUG >= 1)
-// qDebug() << "visual order is:";
+// qDebug("visual order is:");
// for (i = 0; i < numItems; i++)
// qDebug() << visualOrder[i];
#endif
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 8902d52b28..128966a35a 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -2976,7 +2976,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const
}
}
// right of last item
-// qDebug() << "right of last";
+// qDebug("right of last");
int item = visualOrder[nItems-1]+firstItem;
QScriptItem &si = eng->layoutData->items[item];
if (!si.num_glyphs)
diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp
index 4baa94edd5..bd2a9d5183 100644
--- a/src/gui/text/qtextodfwriter.cpp
+++ b/src/gui/text/qtextodfwriter.cpp
@@ -769,7 +769,7 @@ bool QTextOdfWriter::writeAll()
m_strategy = new QXmlStreamStrategy(m_device);
if (!m_device->isWritable() && ! m_device->open(QIODevice::WriteOnly)) {
- qWarning() << "QTextOdfWriter::writeAll: the device can not be opened for writing";
+ qWarning("QTextOdfWriter::writeAll: the device can not be opened for writing");
return false;
}
QXmlStreamWriter writer(m_strategy->contentStream);
diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp
index 4f43f73d41..e42c268493 100644
--- a/src/gui/text/qzip.cpp
+++ b/src/gui/text/qzip.cpp
@@ -574,7 +574,7 @@ void QZipReaderPrivate::scanFiles()
uchar tmp[4];
device->read((char *)tmp, 4);
if (readUInt(tmp) != 0x04034b50) {
- qWarning() << "QZip: not a zip file!";
+ qWarning("QZip: not a zip file!");
return;
}
@@ -586,7 +586,7 @@ void QZipReaderPrivate::scanFiles()
while (start_of_directory == -1) {
const int pos = device->size() - int(sizeof(EndOfDirectory)) - i;
if (pos < 0 || i > 65535) {
- qWarning() << "QZip: EndOfDirectory not found";
+ qWarning("QZip: EndOfDirectory not found");
return;
}
@@ -603,7 +603,7 @@ void QZipReaderPrivate::scanFiles()
ZDEBUG("start_of_directory at %d, num_dir_entries=%d", start_of_directory, num_dir_entries);
int comment_length = readUShort(eod.comment_length);
if (comment_length != i)
- qWarning() << "QZip: failed to parse zip file.";
+ qWarning("QZip: failed to parse zip file.");
comment = device->read(qMin(comment_length, i));
@@ -612,30 +612,30 @@ void QZipReaderPrivate::scanFiles()
FileHeader header;
int read = device->read((char *) &header.h, sizeof(CentralFileHeader));
if (read < (int)sizeof(CentralFileHeader)) {
- qWarning() << "QZip: Failed to read complete header, index may be incomplete";
+ qWarning("QZip: Failed to read complete header, index may be incomplete");
break;
}
if (readUInt(header.h.signature) != 0x02014b50) {
- qWarning() << "QZip: invalid header signature, index may be incomplete";
+ qWarning("QZip: invalid header signature, index may be incomplete");
break;
}
int l = readUShort(header.h.file_name_length);
header.file_name = device->read(l);
if (header.file_name.length() != l) {
- qWarning() << "QZip: Failed to read filename from zip index, index may be incomplete";
+ qWarning("QZip: Failed to read filename from zip index, index may be incomplete");
break;
}
l = readUShort(header.h.extra_field_length);
header.extra_field = device->read(l);
if (header.extra_field.length() != l) {
- qWarning() << "QZip: Failed to read extra field in zip file, skipping file, index may be incomplete";
+ qWarning("QZip: Failed to read extra field in zip file, skipping file, index may be incomplete");
break;
}
l = readUShort(header.h.file_comment_length);
header.file_comment = device->read(l);
if (header.file_comment.length() != l) {
- qWarning() << "QZip: Failed to read read file comment, index may be incomplete";
+ qWarning("QZip: Failed to read read file comment, index may be incomplete");
break;
}