diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-10-17 17:48:34 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-03-12 17:29:36 +0000 |
commit | 6417bbde8565e0be2d049426b71e6fda538e4440 (patch) | |
tree | 8e60f1edf1f8e0f07fc1e6eed23e44389bdb9a67 /src/printsupport | |
parent | 8c0ae00dd603bfe5aa99b5b2db8c1ffdaa6cd45e (diff) |
QtBase (remainder): 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("...").
Had to fix broken qImDebug() definition. Instead of defining it as
a nullary macro in the QT_NO_DEBUG case and as a variadic macro in
the other, define it in both cases, as is customary, as a non-function
macro so that overload selection works without requiring variadic
macro support of the compiler.
Saves e.g. ~250b in text size in QtPrintSupport on optimized GCC 5.3
AMD64 builds.
Change-Id: Ie30fe2f7942115d5dbf99fff1750ae0d477c379f
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Diffstat (limited to 'src/printsupport')
-rw-r--r-- | src/printsupport/kernel/qprintengine_win.cpp | 10 | ||||
-rw-r--r-- | src/printsupport/kernel/qprinter.cpp | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp index 387dfca9c6..edf4dcb164 100644 --- a/src/printsupport/kernel/qprintengine_win.cpp +++ b/src/printsupport/kernel/qprintengine_win.cpp @@ -169,7 +169,7 @@ bool QWin32PrintEngine::begin(QPaintDevice *pdev) cleanUp(); #ifdef QT_DEBUG_METRICS - qDebug() << "QWin32PrintEngine::begin()"; + qDebug("QWin32PrintEngine::begin()"); d->debugMetrics(); #endif // QT_DEBUG_METRICS @@ -236,7 +236,7 @@ bool QWin32PrintEngine::newPage() SetBkMode(d->hdc, TRANSPARENT); #ifdef QT_DEBUG_METRICS - qDebug() << "QWin32PrintEngine::newPage()"; + qDebug("QWin32PrintEngine::newPage()"); d->debugMetrics(); #endif // QT_DEBUG_METRICS @@ -930,7 +930,7 @@ void QWin32PrintEnginePrivate::initialize() initHDC(); #if defined QT_DEBUG_DRAW || defined QT_DEBUG_METRICS - qDebug() << "QWin32PrintEngine::initialize()"; + qDebug("QWin32PrintEngine::initialize()"); debugMetrics(); #endif // QT_DEBUG_DRAW || QT_DEBUG_METRICS } @@ -1007,7 +1007,7 @@ void QWin32PrintEnginePrivate::doReinit() bool QWin32PrintEnginePrivate::resetDC() { if (!hdc) { - qWarning() << "ResetDC() called with null hdc."; + qWarning("ResetDC() called with null hdc."); return false; } const HDC oldHdc = hdc; @@ -1593,7 +1593,7 @@ void QWin32PrintEngine::setGlobalDevMode(HGLOBAL globalDevNames, HGLOBAL globalD d->initHDC(); #if defined QT_DEBUG_DRAW || defined QT_DEBUG_METRICS - qDebug() << "QWin32PrintEngine::setGlobalDevMode()"; + qDebug("QWin32PrintEngine::setGlobalDevMode()"); debugMetrics(); #endif // QT_DEBUG_DRAW || QT_DEBUG_METRICS } diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp index cbab151ea0..584be11199 100644 --- a/src/printsupport/kernel/qprinter.cpp +++ b/src/printsupport/kernel/qprinter.cpp @@ -2135,7 +2135,7 @@ int QPrinter::toPage() const void QPrinter::setFromTo(int from, int to) { if (from > to) { - qWarning() << "QPrinter::setFromTo: 'from' must be less than or equal to 'to'"; + qWarning("QPrinter::setFromTo: 'from' must be less than or equal to 'to'"); from = to; } d->fromPage = from; |