summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-10-24 22:31:27 +0200
committerMarc Mutz <marc.mutz@kdab.com>2016-05-03 04:35:06 +0000
commit5a76a3fb03f8d1dc8cb367de1a1dc6a37048376a (patch)
tree2328d894da121bd0912cb9777f6254cc62296946 /src/widgets
parent0eaac0a3a95f8a74c06d062d3aa7928cbb09d493 (diff)
QtBase: use printf-style qWarning/qDebug where possible (II)
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 second part, replace qWarning() << "" << non-QString with qWarning("..%.", non-QString). QString (and QUrl etc) have special escaping handling when streamed into QDebug, so leave those alone. They also seem to expand to less code than the qPrintable() alternative, so there's no reason to replace them. Saves 2KiB, 3.4KiB, ~750b and ~450b in text size in QtCore, Gui, Network and Widgets, resp., on optimized GCC 5.3 AMD64 builds. Change-Id: Iae6823e543544347e628ca1060d6d51e3b04d3f4 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/accessible/itemviews.cpp4
-rw-r--r--src/widgets/kernel/qgesturemanager.cpp2
-rw-r--r--src/widgets/widgets/qmaccocoaviewcontainer_mac.mm5
-rw-r--r--src/widgets/widgets/qmacnativewidget_mac.mm5
-rw-r--r--src/widgets/widgets/qmenu_mac.mm5
5 files changed, 12 insertions, 9 deletions
diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp
index ebe8efc79e..ecb84d8b50 100644
--- a/src/widgets/accessible/itemviews.cpp
+++ b/src/widgets/accessible/itemviews.cpp
@@ -512,7 +512,7 @@ QAccessibleInterface *QAccessibleTable::child(int logicalIndex) const
if (!iface) {
QModelIndex index = view()->model()->index(row, column, view()->rootIndex());
if (Q_UNLIKELY(!index.isValid())) {
- qWarning() << "QAccessibleTable::child: Invalid index at: " << row << column;
+ qWarning("QAccessibleTable::child: Invalid index at: %d %d", row, column);
return 0;
}
iface = new QAccessibleTableCell(view(), index, cellRole());
@@ -783,7 +783,7 @@ QAccessibleInterface *QAccessibleTree::cellAt(int row, int column) const
{
QModelIndex index = indexFromLogical(row, column);
if (Q_UNLIKELY(!index.isValid())) {
- qWarning() << "Requested invalid tree cell: " << row << column;
+ qWarning("Requested invalid tree cell: %d %d", row, column);
return 0;
}
const QTreeView *treeView = qobject_cast<const QTreeView*>(view());
diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp
index 8af3516d4b..777be8525e 100644
--- a/src/widgets/kernel/qgesturemanager.cpp
+++ b/src/widgets/kernel/qgesturemanager.cpp
@@ -75,7 +75,7 @@ static inline int panTouchPoints()
const int result = qEnvironmentVariableIntValue(panTouchPointVariable, &ok);
if (ok && result >= 1)
return result;
- qWarning() << "Ignoring invalid value of " << panTouchPointVariable;
+ qWarning("Ignoring invalid value of %s", panTouchPointVariable);
}
// Pan should use 1 finger on a touch screen and 2 fingers on touch pads etc.
// where 1 finger movements are used for mouse event synthetization. For now,
diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
index 477bb92601..2d19780461 100644
--- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
+++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
@@ -100,8 +100,9 @@ inline QPlatformNativeInterface::NativeResourceForIntegrationFunction resolvePla
QPlatformNativeInterface::NativeResourceForIntegrationFunction function =
nativeInterface->nativeResourceFunctionForIntegration(functionName);
if (Q_UNLIKELY(!function))
- qWarning() << "Qt could not resolve function" << functionName
- << "from QGuiApplication::platformNativeInterface()->nativeResourceFunctionForIntegration()";
+ qWarning("Qt could not resolve function %s from "
+ "QGuiApplication::platformNativeInterface()->nativeResourceFunctionForIntegration()",
+ functionName.constData());
return function;
}
} //namespsace
diff --git a/src/widgets/widgets/qmacnativewidget_mac.mm b/src/widgets/widgets/qmacnativewidget_mac.mm
index 6c113b556f..b6c5179989 100644
--- a/src/widgets/widgets/qmacnativewidget_mac.mm
+++ b/src/widgets/widgets/qmacnativewidget_mac.mm
@@ -89,8 +89,9 @@ inline QPlatformNativeInterface::NativeResourceForIntegrationFunction resolvePla
QPlatformNativeInterface::NativeResourceForIntegrationFunction function =
nativeInterface->nativeResourceFunctionForIntegration(functionName);
if (Q_UNLIKELY(!function))
- qWarning() << "Qt could not resolve function" << functionName
- << "from QGuiApplication::platformNativeInterface()->nativeResourceFunctionForIntegration()";
+ qWarning("Qt could not resolve function %s from "
+ "QGuiApplication::platformNativeInterface()->nativeResourceFunctionForIntegration()",
+ functionName.constData());
return function;
}
} //namespsace
diff --git a/src/widgets/widgets/qmenu_mac.mm b/src/widgets/widgets/qmenu_mac.mm
index 29f5913b5d..d48041b385 100644
--- a/src/widgets/widgets/qmenu_mac.mm
+++ b/src/widgets/widgets/qmenu_mac.mm
@@ -62,8 +62,9 @@ inline QPlatformNativeInterface::NativeResourceForIntegrationFunction resolvePla
QPlatformNativeInterface::NativeResourceForIntegrationFunction function =
nativeInterface->nativeResourceFunctionForIntegration(functionName);
if (Q_UNLIKELY(!function))
- qWarning() << "Qt could not resolve function" << functionName
- << "from QGuiApplication::platformNativeInterface()->nativeResourceFunctionForIntegration()";
+ qWarning("Qt could not resolve function %s from "
+ "QGuiApplication::platformNativeInterface()->nativeResourceFunctionForIntegration()",
+ functionName.constData());
return function;
}
} //namespsace