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-04 10:29:08 +0000 |
commit | 600529e07a46d8e20f4302dc988125f3fee36ec4 (patch) | |
tree | d1ef58c493d6f9dd2521c63ce1f07e04a7aa5658 /src/gui/kernel | |
parent | b6b3803b213787a04dfc7542caeb541a5535d90f (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/kernel')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qopenglcontext.cpp | 8 | ||||
-rw-r--r-- | src/gui/kernel/qstylehints.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 4 |
4 files changed, 9 insertions, 9 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index e4d7ad8fcd..057450374d 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1437,7 +1437,7 @@ void QGuiApplicationPrivate::init() typedef void (*TasInitialize)(void); TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init"); if (Q_UNLIKELY(!initFunction)) { - qCritical() << "Library qttestability resolve failed!"; + qCritical("Library qttestability resolve failed!"); } else { initFunction(); } @@ -1595,7 +1595,7 @@ QFunctionPointer QGuiApplication::platformFunction(const QByteArray &function) { QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration(); if (!pi) { - qWarning() << "QGuiApplication::platformFunction(): Must construct a QGuiApplication before accessing a platform function"; + qWarning("QGuiApplication::platformFunction(): Must construct a QGuiApplication before accessing a platform function"); return Q_NULLPTR; } diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 61324d73f3..81c0971ea0 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -1033,19 +1033,19 @@ void QOpenGLContext::swapBuffers(QSurface *surface) return; if (!surface) { - qWarning() << "QOpenGLContext::swapBuffers() called with null argument"; + qWarning("QOpenGLContext::swapBuffers() called with null argument"); return; } if (!surface->supportsOpenGL()) { - qWarning() << "QOpenGLContext::swapBuffers() called with non-opengl surface"; + qWarning("QOpenGLContext::swapBuffers() called with non-opengl surface"); return; } if (surface->surfaceClass() == QSurface::Window && !qt_window_private(static_cast<QWindow *>(surface))->receivedExpose) { - qWarning() << "QOpenGLContext::swapBuffers() called with non-exposed window, behavior is undefined"; + qWarning("QOpenGLContext::swapBuffers() called with non-exposed window, behavior is undefined"); } QPlatformSurface *surfaceHandle = surface->surfaceHandle(); @@ -1054,7 +1054,7 @@ void QOpenGLContext::swapBuffers(QSurface *surface) #if !defined(QT_NO_DEBUG) if (!QOpenGLContextPrivate::toggleMakeCurrentTracker(this, false)) - qWarning() << "QOpenGLContext::swapBuffers() called without corresponding makeCurrent()"; + qWarning("QOpenGLContext::swapBuffers() called without corresponding makeCurrent()"); #endif if (surface->format().swapBehavior() == QSurfaceFormat::SingleBuffer) functions()->glFlush(); diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index e184fed275..ecc2886a04 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -54,7 +54,7 @@ static inline QVariant themeableHint(QPlatformTheme::ThemeHint th, QPlatformIntegration::StyleHint ih) { if (!QCoreApplication::instance()) { - qWarning() << "Must construct a QGuiApplication before accessing a platform theme hint."; + qWarning("Must construct a QGuiApplication before accessing a platform theme hint."); return QVariant(); } if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index f43ef43c6c..3f430be579 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -1145,7 +1145,7 @@ qreal QWindow::devicePixelRatio() const void QWindow::setWindowState(Qt::WindowState state) { if (state == Qt::WindowActive) { - qWarning() << "QWindow::setWindowState does not accept Qt::WindowActive"; + qWarning("QWindow::setWindowState does not accept Qt::WindowActive"); return; } @@ -2436,7 +2436,7 @@ QWindow *QWindowPrivate::topLevelWindow() const QWindow *QWindow::fromWinId(WId id) { if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ForeignWindows)) { - qWarning() << "QWindow::fromWinId(): platform plugin does not support foreign windows."; + qWarning("QWindow::fromWinId(): platform plugin does not support foreign windows."); return 0; } |