diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-10-17 17:48:34 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-10-27 11:10:24 +0000 |
commit | 29a7f5571cb3619898d8d05c09f7df4ece915aed (patch) | |
tree | f8bfe9dfa683b71c829f14a32de3bd7491310680 /src/widgets/graphicsview | |
parent | f8eeabcf5ca4615fcb3ed783dbd321f4998a7651 (diff) |
QtWidgets: 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("...");
Change-Id: I1f6869b024103c98262f1deae014e0d7337a541c
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/widgets/graphicsview')
-rw-r--r-- | src/widgets/graphicsview/qgraphicslinearlayout.cpp | 2 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicsproxywidget.cpp | 20 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicswidget.cpp | 2 | ||||
-rw-r--r-- | src/widgets/graphicsview/qsimplex_p.cpp | 8 |
4 files changed, 16 insertions, 16 deletions
diff --git a/src/widgets/graphicsview/qgraphicslinearlayout.cpp b/src/widgets/graphicsview/qgraphicslinearlayout.cpp index efdf6a595c..0384364ad4 100644 --- a/src/widgets/graphicsview/qgraphicslinearlayout.cpp +++ b/src/widgets/graphicsview/qgraphicslinearlayout.cpp @@ -512,7 +512,7 @@ void QGraphicsLinearLayout::setGeometry(const QRectF &rect) d->engine.setGeometries(effectiveRect, d->styleInfo()); #ifdef QGRIDLAYOUTENGINE_DEBUG if (qt_graphicsLayoutDebug()) { - qDebug() << "post dump"; + qDebug("post dump"); dump(1); } #endif diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp index edb0f4e0ff..88bed7cf0e 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp +++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp @@ -1168,7 +1168,7 @@ void QGraphicsProxyWidget::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_D(QGraphicsProxyWidget); #ifdef GRAPHICSPROXYWIDGET_DEBUG - qDebug() << "QGraphicsProxyWidget::hoverMoveEvent"; + qDebug("QGraphicsProxyWidget::hoverMoveEvent"); #endif // Ignore events on the window frame. if (!d->widget || !rect().contains(event->pos())) { @@ -1208,7 +1208,7 @@ void QGraphicsProxyWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { Q_D(QGraphicsProxyWidget); #ifdef GRAPHICSPROXYWIDGET_DEBUG - qDebug() << "QGraphicsProxyWidget::mouseMoveEvent"; + qDebug("QGraphicsProxyWidget::mouseMoveEvent"); #endif d->sendWidgetMouseEvent(event); } @@ -1220,7 +1220,7 @@ void QGraphicsProxyWidget::mousePressEvent(QGraphicsSceneMouseEvent *event) { Q_D(QGraphicsProxyWidget); #ifdef GRAPHICSPROXYWIDGET_DEBUG - qDebug() << "QGraphicsProxyWidget::mousePressEvent"; + qDebug("QGraphicsProxyWidget::mousePressEvent"); #endif d->sendWidgetMouseEvent(event); } @@ -1232,7 +1232,7 @@ void QGraphicsProxyWidget::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event { Q_D(QGraphicsProxyWidget); #ifdef GRAPHICSPROXYWIDGET_DEBUG - qDebug() << "QGraphicsProxyWidget::mouseDoubleClickEvent"; + qDebug("QGraphicsProxyWidget::mouseDoubleClickEvent"); #endif d->sendWidgetMouseEvent(event); } @@ -1245,7 +1245,7 @@ void QGraphicsProxyWidget::wheelEvent(QGraphicsSceneWheelEvent *event) { Q_D(QGraphicsProxyWidget); #ifdef GRAPHICSPROXYWIDGET_DEBUG - qDebug() << "QGraphicsProxyWidget::wheelEvent"; + qDebug("QGraphicsProxyWidget::wheelEvent"); #endif if (!d->widget) return; @@ -1283,7 +1283,7 @@ void QGraphicsProxyWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { Q_D(QGraphicsProxyWidget); #ifdef GRAPHICSPROXYWIDGET_DEBUG - qDebug() << "QGraphicsProxyWidget::mouseReleaseEvent"; + qDebug("QGraphicsProxyWidget::mouseReleaseEvent"); #endif d->sendWidgetMouseEvent(event); } @@ -1295,7 +1295,7 @@ void QGraphicsProxyWidget::keyPressEvent(QKeyEvent *event) { Q_D(QGraphicsProxyWidget); #ifdef GRAPHICSPROXYWIDGET_DEBUG - qDebug() << "QGraphicsProxyWidget::keyPressEvent"; + qDebug("QGraphicsProxyWidget::keyPressEvent"); #endif d->sendWidgetKeyEvent(event); } @@ -1307,7 +1307,7 @@ void QGraphicsProxyWidget::keyReleaseEvent(QKeyEvent *event) { Q_D(QGraphicsProxyWidget); #ifdef GRAPHICSPROXYWIDGET_DEBUG - qDebug() << "QGraphicsProxyWidget::keyReleaseEvent"; + qDebug("QGraphicsProxyWidget::keyReleaseEvent"); #endif d->sendWidgetKeyEvent(event); } @@ -1318,7 +1318,7 @@ void QGraphicsProxyWidget::keyReleaseEvent(QKeyEvent *event) void QGraphicsProxyWidget::focusInEvent(QFocusEvent *event) { #ifdef GRAPHICSPROXYWIDGET_DEBUG - qDebug() << "QGraphicsProxyWidget::focusInEvent"; + qDebug("QGraphicsProxyWidget::focusInEvent"); #endif Q_D(QGraphicsProxyWidget); @@ -1357,7 +1357,7 @@ void QGraphicsProxyWidget::focusInEvent(QFocusEvent *event) void QGraphicsProxyWidget::focusOutEvent(QFocusEvent *event) { #ifdef GRAPHICSPROXYWIDGET_DEBUG - qDebug() << "QGraphicsProxyWidget::focusOutEvent"; + qDebug("QGraphicsProxyWidget::focusOutEvent"); #endif Q_D(QGraphicsProxyWidget); if (d->widget) { diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp index 67311ed2c3..8ffb60411c 100644 --- a/src/widgets/graphicsview/qgraphicswidget.cpp +++ b/src/widgets/graphicsview/qgraphicswidget.cpp @@ -2398,7 +2398,7 @@ bool QGraphicsWidget::close() #if 0 void QGraphicsWidget::dumpFocusChain() { - qDebug() << "=========== Dumping focus chain =============="; + qDebug("=========== Dumping focus chain =============="); int i = 0; QGraphicsWidget *next = this; QSet<QGraphicsWidget*> visited; diff --git a/src/widgets/graphicsview/qsimplex_p.cpp b/src/widgets/graphicsview/qsimplex_p.cpp index 1aeade6640..b827ab1400 100644 --- a/src/widgets/graphicsview/qsimplex_p.cpp +++ b/src/widgets/graphicsview/qsimplex_p.cpp @@ -140,7 +140,7 @@ bool QSimplex::setConstraints(const QList<QSimplexConstraint *> &newConstraints) // Remove constraints of type Var == K and replace them for their value. if (!simplifyConstraints(&constraints)) { - qWarning() << "QSimplex: No feasible solution!"; + qWarning("QSimplex: No feasible solution!"); clearDataStructures(); return false; } @@ -230,7 +230,7 @@ bool QSimplex::setConstraints(const QList<QSimplexConstraint *> &newConstraints) matrix = (qreal *)malloc(sizeof(qreal) * columns * rows); if (!matrix) { - qWarning() << "QSimplex: Unable to allocate memory!"; + qWarning("QSimplex: Unable to allocate memory!"); return false; } for (int i = columns * rows - 1; i >= 0; --i) @@ -281,7 +281,7 @@ bool QSimplex::setConstraints(const QList<QSimplexConstraint *> &newConstraints) // Otherwise, we clean up our structures and report there is // no feasible solution. if ((valueAt(0, columns - 1) != 0.0) && (qAbs(valueAt(0, columns - 1)) > 0.00001)) { - qWarning() << "QSimplex: No feasible solution!"; + qWarning("QSimplex: No feasible solution!"); clearDataStructures(); return false; } @@ -471,7 +471,7 @@ bool QSimplex::iterate() // Find Pivot row for column int pivotRow = pivotRowForColumn(pivotColumn); if (pivotRow == -1) { - qWarning() << "QSimplex: Unbounded problem!"; + qWarning("QSimplex: Unbounded problem!"); return false; } |