summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-10-17 17:48:34 +0200
committerMarc Mutz <marc.mutz@kdab.com>2015-10-27 11:10:24 +0000
commit29a7f5571cb3619898d8d05c09f7df4ece915aed (patch)
treef8bfe9dfa683b71c829f14a32de3bd7491310680 /src
parentf8eeabcf5ca4615fcb3ed783dbd321f4998a7651 (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')
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp4
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp2
-rw-r--r--src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsview.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicslinearlayout.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget.cpp20
-rw-r--r--src/widgets/graphicsview/qgraphicswidget.cpp2
-rw-r--r--src/widgets/graphicsview/qsimplex_p.cpp8
-rw-r--r--src/widgets/itemviews/qtableview.cpp7
-rw-r--r--src/widgets/itemviews/qtreewidget.cpp2
-rw-r--r--src/widgets/kernel/qopenglwidget.cpp4
-rw-r--r--src/widgets/kernel/qwidget.cpp2
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm4
-rw-r--r--src/widgets/util/qflickgesture.cpp8
-rw-r--r--src/widgets/util/qscroller.cpp2
-rw-r--r--src/widgets/widgets/qdockwidget.cpp2
-rw-r--r--src/widgets/widgets/qtoolbarlayout.cpp2
16 files changed, 37 insertions, 36 deletions
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 443213d0de..cd26a6759f 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -977,7 +977,7 @@ void QFileDialog::setDirectoryUrl(const QUrl &directory)
else if (directory.isLocalFile())
setDirectory(directory.toLocalFile());
else if (d->usingWidgets())
- qWarning() << "Non-native QFileDialog supports only local files";
+ qWarning("Non-native QFileDialog supports only local files");
}
/*!
@@ -1087,7 +1087,7 @@ void QFileDialog::selectUrl(const QUrl &url)
else if (url.isLocalFile())
selectFile(url.toLocalFile());
else
- qWarning() << "Non-native QFileDialog supports only local files";
+ qWarning("Non-native QFileDialog supports only local files");
}
#ifdef Q_OS_UNIX
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index 67af7f8107..b1e77540e7 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -473,7 +473,7 @@ void QFileSystemModel::timerEvent(QTimerEvent *event)
d->fileInfoGatherer.fetchExtendedInformation(d->toFetch.at(i).dir,
QStringList(d->toFetch.at(i).file));
} else {
- // qDebug() << "yah!, you saved a little gerbil soul";
+ // qDebug("yah!, you saved a little gerbil soul");
}
}
#endif
diff --git a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsview.cpp b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsview.cpp
index 2f6865c9dd..074b214f80 100644
--- a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsview.cpp
+++ b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsview.cpp
@@ -116,7 +116,7 @@ void CustomView::mousePressEvent(QMouseEvent *event)
if (QGraphicsItem *item = itemAt(event->pos())) {
qDebug() << "You clicked on item" << item;
} else {
- qDebug() << "You didn't click on an item.";
+ qDebug("You didn't click on an item.");
}
}
//! [6]
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;
}
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp
index 0af4a26494..89bd9dbcb1 100644
--- a/src/widgets/itemviews/qtableview.cpp
+++ b/src/widgets/itemviews/qtableview.cpp
@@ -670,13 +670,14 @@ void QTableViewPrivate::trimHiddenSelections(QItemSelectionRange *range) const
void QTableViewPrivate::setSpan(int row, int column, int rowSpan, int columnSpan)
{
if (row < 0 || column < 0 || rowSpan <= 0 || columnSpan <= 0) {
- qWarning() << "QTableView::setSpan: invalid span given: (" << row << ',' << column << ',' << rowSpan << ',' << columnSpan << ')';
+ qWarning("QTableView::setSpan: invalid span given: (%d, %d, %d, %d)",
+ row, column, rowSpan, columnSpan);
return;
}
QSpanCollection::Span *sp = spans.spanAt(column, row);
if (sp) {
if (sp->top() != row || sp->left() != column) {
- qWarning() << "QTableView::setSpan: span cannot overlap";
+ qWarning("QTableView::setSpan: span cannot overlap");
return;
}
if (rowSpan == 1 && columnSpan == 1) {
@@ -688,7 +689,7 @@ void QTableViewPrivate::setSpan(int row, int column, int rowSpan, int columnSpan
spans.updateSpan(sp, old_height);
return;
} else if (rowSpan == 1 && columnSpan == 1) {
- qWarning() << "QTableView::setSpan: single cell span won't be added";
+ qWarning("QTableView::setSpan: single cell span won't be added");
return;
}
sp = new QSpanCollection::Span(row, column, rowSpan, columnSpan);
diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp
index db4451c99a..676893ebf0 100644
--- a/src/widgets/itemviews/qtreewidget.cpp
+++ b/src/widgets/itemviews/qtreewidget.cpp
@@ -3281,7 +3281,7 @@ QMimeData *QTreeWidget::mimeData(const QList<QTreeWidgetItem*> items) const
for (int i = 0; i < items.count(); ++i) {
QTreeWidgetItem *item = items.at(i);
if (!item) {
- qWarning() << "QTreeWidget::mimeData: Null-item passed";
+ qWarning("QTreeWidget::mimeData: Null-item passed");
return 0;
}
diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp
index 65a70ceb02..389539bb18 100644
--- a/src/widgets/kernel/qopenglwidget.cpp
+++ b/src/widgets/kernel/qopenglwidget.cpp
@@ -647,8 +647,8 @@ GLuint QOpenGLWidgetPrivate::textureId() const
{
Q_Q(const QOpenGLWidget);
if (!q->isWindow() && q->internalWinId()) {
- qWarning() << "QOpenGLWidget cannot be used as a native child widget."
- << "Consider setting Qt::WA_DontCreateNativeAncestors and Qt::AA_DontCreateNativeWidgetSiblings.";
+ qWarning("QOpenGLWidget cannot be used as a native child widget. Consider setting "
+ "Qt::WA_DontCreateNativeAncestors and Qt::AA_DontCreateNativeWidgetSiblings");
return 0;
}
return resolvedFbo ? resolvedFbo->texture() : (fbo ? fbo->texture() : 0);
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index a006246454..773471533e 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -12099,7 +12099,7 @@ QOpenGLContext *QWidgetPrivate::shareContext() const
return 0;
#else
if (!extra || !extra->topextra || !extra->topextra->window) {
- qWarning() << "Asking for share context for widget that does not have a window handle";
+ qWarning("Asking for share context for widget that does not have a window handle");
return 0;
}
QWidgetPrivate *that = const_cast<QWidgetPrivate *>(this);
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index e8da137654..a1c5e82ad1 100644
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -7191,7 +7191,7 @@ CGContextRef qt_mac_cg_context(const QPaintDevice *pdev)
ret = CGBitmapContextCreate(image->bits(), image->width(), image->height(),
8, image->bytesPerLine(), colorspace, flags);
} else {
- qDebug() << "qt_mac_cg_context: Unsupported pixmap class";
+ qDebug("qt_mac_cg_context: Unsupported pixmap class");
}
CGContextTranslateCTM(ret, 0, pm->height());
@@ -7203,7 +7203,7 @@ CGContextRef qt_mac_cg_context(const QPaintDevice *pdev)
//CGContextRef ret = static_cast<CGContextRef>(static_cast<const QWidget *>(pdev)->macCGHandle());
///CGContextRetain(ret);
//return ret;
- qDebug() << "qt_mac_cg_context: not implemented: Widget class";
+ qDebug("qt_mac_cg_context: not implemented: Widget class");
return 0;
}
return 0;
diff --git a/src/widgets/util/qflickgesture.cpp b/src/widgets/util/qflickgesture.cpp
index 8eadc42625..c7e0861a0f 100644
--- a/src/widgets/util/qflickgesture.cpp
+++ b/src/widgets/util/qflickgesture.cpp
@@ -155,9 +155,9 @@ public:
mouseTarget = QApplication::widgetAt(pressDelayEvent->globalPos());
mouseButton = pressDelayEvent->button();
mouseEventSource = pressDelayEvent->source();
- qFGDebug() << "QFG: consuming/delaying mouse press";
+ qFGDebug("QFG: consuming/delaying mouse press");
} else {
- qFGDebug() << "QFG: NOT consuming/delaying mouse press";
+ qFGDebug("QFG: NOT consuming/delaying mouse press");
}
e->setAccepted(true);
}
@@ -194,7 +194,7 @@ public:
void scrollerWasIntercepted()
{
- qFGDebug() << "QFG: deleting delayed mouse press, since scroller was only intercepted";
+ qFGDebug("QFG: deleting delayed mouse press, since scroller was only intercepted");
if (pressDelayEvent) {
// we still haven't even sent the press, so just throw it away now
if (pressDelayTimer) {
@@ -210,7 +210,7 @@ public:
{
if (pressDelayEvent) {
// we still haven't even sent the press, so just throw it away now
- qFGDebug() << "QFG: deleting delayed mouse press, since scroller is active now";
+ qFGDebug("QFG: deleting delayed mouse press, since scroller is active now");
if (pressDelayTimer) {
killTimer(pressDelayTimer);
pressDelayTimer = 0;
diff --git a/src/widgets/util/qscroller.cpp b/src/widgets/util/qscroller.cpp
index 563c501356..0065ccf6b3 100644
--- a/src/widgets/util/qscroller.cpp
+++ b/src/widgets/util/qscroller.cpp
@@ -1668,7 +1668,7 @@ bool QScrollerPrivate::releaseWhileDragging(const QPointF &position, qint64 time
void QScrollerPrivate::timerEventWhileScrolling()
{
- qScrollerDebug() << "QScroller::timerEventWhileScrolling()";
+ qScrollerDebug("QScroller::timerEventWhileScrolling()");
setContentPositionHelperScrolling();
if (xSegments.isEmpty() && ySegments.isEmpty())
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index 8b0263fc0c..b30f49bea6 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -245,7 +245,7 @@ bool QDockWidgetLayout::nativeWindowDeco(bool floating) const
void QDockWidgetLayout::addItem(QLayoutItem*)
{
- qWarning() << "QDockWidgetLayout::addItem(): please use QDockWidgetLayout::setWidget()";
+ qWarning("QDockWidgetLayout::addItem(): please use QDockWidgetLayout::setWidget()");
return;
}
diff --git a/src/widgets/widgets/qtoolbarlayout.cpp b/src/widgets/widgets/qtoolbarlayout.cpp
index d478b028a6..42fd93fda2 100644
--- a/src/widgets/widgets/qtoolbarlayout.cpp
+++ b/src/widgets/widgets/qtoolbarlayout.cpp
@@ -153,7 +153,7 @@ void QToolBarLayout::checkUsePopupMenu()
void QToolBarLayout::addItem(QLayoutItem*)
{
- qWarning() << "QToolBarLayout::addItem(): please use addAction() instead";
+ qWarning("QToolBarLayout::addItem(): please use addAction() instead");
return;
}