From 0325842b9926f87f22beb3b8dda32c20b2f994ec Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 12 Nov 2015 10:16:22 +0100 Subject: [PATCH] QtWidgets: use Q_UNLIKELY for every qWarning() (2) If, after checking a condition, we issue a qWarning(), by definition that check is unlikely to be true. Tell the compiler so it can move the error handling code out of the normal code path to increase the effective icache size. This change contains the changes to the accessible/, effects/, kernel/, styles/ and itemviews/ subdirs. Moved conditional code around where possible so that we could always use Q_UNLIKELY, instead of having to revert to Q_LIKELY here and there. In QWidgetPrivate::setWindowModified_helper(), as a drive-by, I swapped the evaluation order of an &&-expression (newly wrapped in Q_UNLIKELY) to be more readable and more efficient (cheaper check first) at the same time. In qDraw* (qdrawutil.cpp), simplified boolean expressions (sometimes by skipping re-checking conditions already checked in a previous guard clause). Change-Id: I58be22be0a33522c2629a66c2f6c795771a99f3f Reviewed-by: Lars Knoll --- src/widgets/accessible/itemviews.cpp | 10 ++--- src/widgets/accessible/qaccessiblewidget.cpp | 2 +- src/widgets/accessible/qaccessiblewidgets.cpp | 2 +- src/widgets/effects/qgraphicseffect.cpp | 4 +- src/widgets/itemviews/qabstractitemview.cpp | 8 ++-- src/widgets/itemviews/qdirmodel.cpp | 4 +- src/widgets/itemviews/qlistview.cpp | 2 +- src/widgets/itemviews/qtableview.cpp | 4 +- src/widgets/itemviews/qtablewidget.cpp | 2 +- src/widgets/itemviews/qtreewidget.cpp | 4 +- src/widgets/kernel/qaction.cpp | 2 +- src/widgets/kernel/qapplication.cpp | 8 ++-- src/widgets/kernel/qdesktopwidget.cpp | 4 +- src/widgets/kernel/qformlayout.cpp | 8 ++-- src/widgets/kernel/qgesturemanager.cpp | 14 +++---- src/widgets/kernel/qgridlayout.cpp | 6 +-- src/widgets/kernel/qlayout.cpp | 22 +++++------ src/widgets/kernel/qopenglwidget.cpp | 14 +++---- src/widgets/kernel/qshortcut.cpp | 4 +- src/widgets/kernel/qstackedlayout.cpp | 12 +++--- src/widgets/kernel/qtooltip.cpp | 8 ++-- src/widgets/kernel/qwidget.cpp | 38 +++++++++---------- src/widgets/kernel/qwidgetbackingstore.cpp | 2 +- src/widgets/kernel/qwidgetwindow.cpp | 2 +- src/widgets/kernel/qwindowcontainer.cpp | 2 +- src/widgets/styles/qandroidstyle.cpp | 2 +- src/widgets/styles/qdrawutil.cpp | 8 ++-- src/widgets/styles/qstylesheetstyle.cpp | 8 ++-- src/widgets/styles/qwindowsvistastyle.cpp | 4 +- src/widgets/styles/qwindowsxpstyle.cpp | 8 ++-- 30 files changed, 109 insertions(+), 109 deletions(-) diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp index 1b724c9a17d..a7c1c750669 100644 --- a/src/widgets/accessible/itemviews.cpp +++ b/src/widgets/accessible/itemviews.cpp @@ -132,7 +132,7 @@ QAccessibleInterface *QAccessibleTable::cellAt(int row, int column) const return 0; Q_ASSERT(role() != QAccessible::Tree); QModelIndex index = view()->model()->index(row, column, view()->rootIndex()); - if (!index.isValid()) { + if (Q_UNLIKELY(!index.isValid())) { qWarning() << "QAccessibleTable::cellAt: invalid index: " << index << " for " << view(); return 0; } @@ -505,7 +505,7 @@ QAccessibleInterface *QAccessibleTable::child(int logicalIndex) const if (!iface) { QModelIndex index = view()->model()->index(row, column, view()->rootIndex()); - if (!index.isValid()) { + if (Q_UNLIKELY(!index.isValid())) { qWarning() << "QAccessibleTable::child: Invalid index at: " << row << column; return 0; } @@ -666,7 +666,7 @@ QModelIndex QAccessibleTree::indexFromLogical(int row, int column) const return QModelIndex(); const QTreeView *treeView = qobject_cast(view()); - if ((row < 0) || (column < 0) || (treeView->d_func()->viewItems.count() <= row)) { + if (Q_UNLIKELY(row < 0 || column < 0 || treeView->d_func()->viewItems.count() <= row)) { qWarning() << "QAccessibleTree::indexFromLogical: invalid index: " << row << column << " for " << treeView; return QModelIndex(); } @@ -776,7 +776,7 @@ int QAccessibleTree::indexOfChild(const QAccessibleInterface *iface) const QAccessibleInterface *QAccessibleTree::cellAt(int row, int column) const { QModelIndex index = indexFromLogical(row, column); - if (!index.isValid()) { + if (Q_UNLIKELY(!index.isValid())) { qWarning() << "Requested invalid tree cell: " << row << column; return 0; } @@ -835,7 +835,7 @@ bool QAccessibleTree::selectRow(int row) QAccessibleTableCell::QAccessibleTableCell(QAbstractItemView *view_, const QModelIndex &index_, QAccessible::Role role_) : /* QAccessibleSimpleEditableTextInterface(this), */ view(view_), m_index(index_), m_role(role_) { - if (!index_.isValid()) + if (Q_UNLIKELY(!index_.isValid())) qWarning() << "QAccessibleTableCell::QAccessibleTableCell with invalid index: " << index_; } diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp index 3a9422cc26f..ed5b6f86fd2 100644 --- a/src/widgets/accessible/qaccessiblewidget.cpp +++ b/src/widgets/accessible/qaccessiblewidget.cpp @@ -274,7 +274,7 @@ public: void QAccessibleWidget::addControllingSignal(const QString &signal) { QByteArray s = QMetaObject::normalizedSignature(signal.toLatin1()); - if (object()->metaObject()->indexOfSignal(s) < 0) + if (Q_UNLIKELY(object()->metaObject()->indexOfSignal(s) < 0)) qWarning("Signal %s unknown in %s", s.constData(), object()->metaObject()->className()); d->primarySignals << QLatin1String(s); } diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp index adf908b8213..a4f433e65ad 100644 --- a/src/widgets/accessible/qaccessiblewidgets.cpp +++ b/src/widgets/accessible/qaccessiblewidgets.cpp @@ -282,7 +282,7 @@ void QAccessibleTextEdit::scrollToSubstring(int startIndex, int endIndex) r.y() + edit->verticalScrollBar()->value()); // E V I L, but ensureVisible is not public - if (!QMetaObject::invokeMethod(edit, "_q_ensureVisible", Q_ARG(QRectF, r))) + if (Q_UNLIKELY(!QMetaObject::invokeMethod(edit, "_q_ensureVisible", Q_ARG(QRectF, r)))) qWarning("AccessibleTextEdit::scrollToSubstring failed!"); } diff --git a/src/widgets/effects/qgraphicseffect.cpp b/src/widgets/effects/qgraphicseffect.cpp index 5a97be3d964..1f1e50d7fb8 100644 --- a/src/widgets/effects/qgraphicseffect.cpp +++ b/src/widgets/effects/qgraphicseffect.cpp @@ -316,8 +316,8 @@ QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offse return pixmapItem->pixmap(); } - if (system == Qt::DeviceCoordinates && item - && !static_cast(d_func())->info) { + if (Q_UNLIKELY(system == Qt::DeviceCoordinates && item && + !static_cast(d_func())->info)) { qWarning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context"); return QPixmap(); } diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index ad7be840d0c..2f7b2a43c4b 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -758,7 +758,7 @@ void QAbstractItemView::setSelectionModel(QItemSelectionModel *selectionModel) Q_ASSERT(selectionModel); Q_D(QAbstractItemView); - if (selectionModel->model() != d->model) { + if (Q_UNLIKELY(selectionModel->model() != d->model)) { qWarning("QAbstractItemView::setSelectionModel() failed: " "Trying to set a selection model, which works on " "a different model than the view."); @@ -1113,7 +1113,7 @@ void QAbstractItemView::reset() void QAbstractItemView::setRootIndex(const QModelIndex &index) { Q_D(QAbstractItemView); - if (index.isValid() && index.model() != d->model) { + if (Q_UNLIKELY(index.isValid() && index.model() != d->model)) { qWarning("QAbstractItemView::setRootIndex failed : index must be from the currently set model"); return; } @@ -1166,9 +1166,9 @@ void QAbstractItemView::selectAll() void QAbstractItemView::edit(const QModelIndex &index) { Q_D(QAbstractItemView); - if (!d->isIndexValid(index)) + if (Q_UNLIKELY(!d->isIndexValid(index))) qWarning("edit: index was invalid"); - if (!edit(index, AllEditTriggers, 0)) + if (Q_UNLIKELY(!edit(index, AllEditTriggers, 0))) qWarning("edit: editing failed"); } diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp index 0c157c940f5..ddc75ef1765 100644 --- a/src/widgets/itemviews/qdirmodel.cpp +++ b/src/widgets/itemviews/qdirmodel.cpp @@ -1022,7 +1022,7 @@ bool QDirModel::rmdir(const QModelIndex &index) return false; QDirModelPrivate::QDirNode *n = d_func()->node(index); - if (!n->info.isDir()) { + if (Q_UNLIKELY(!n->info.isDir())) { qWarning("rmdir: the node is not a directory"); return false; } @@ -1172,7 +1172,7 @@ QDirModelPrivate::QDirNode *QDirModelPrivate::node(int row, QDirNode *parent) co if (isDir && !p->populated) populate(p); // will also resolve symlinks - if (row >= p->children.count()) { + if (Q_UNLIKELY(row >= p->children.count())) { qWarning("node: the row does not exist"); return 0; } diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 9c79509874f..ed1f1f2e984 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -392,7 +392,7 @@ int QListView::spacing() const void QListView::setBatchSize(int batchSize) { Q_D(QListView); - if (batchSize <= 0) { + if (Q_UNLIKELY(batchSize <= 0)) { qWarning("Invalid batchSize (%d)", batchSize); return; } diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index 89bd9dbcb1d..d0dcb02d7f3 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -669,7 +669,7 @@ 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) { + if (Q_UNLIKELY(row < 0 || column < 0 || rowSpan <= 0 || columnSpan <= 0)) { qWarning("QTableView::setSpan: invalid span given: (%d, %d, %d, %d)", row, column, rowSpan, columnSpan); return; @@ -688,7 +688,7 @@ void QTableViewPrivate::setSpan(int row, int column, int rowSpan, int columnSpan sp->m_right = column + columnSpan - 1; spans.updateSpan(sp, old_height); return; - } else if (rowSpan == 1 && columnSpan == 1) { + } else if (Q_UNLIKELY(rowSpan == 1 && columnSpan == 1)) { qWarning("QTableView::setSpan: single cell span won't be added"); return; } diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp index cd38f4b282b..901281e17fc 100644 --- a/src/widgets/itemviews/qtablewidget.cpp +++ b/src/widgets/itemviews/qtablewidget.cpp @@ -1958,7 +1958,7 @@ void QTableWidget::setItem(int row, int column, QTableWidgetItem *item) { Q_D(QTableWidget); if (item) { - if (item->view != 0) { + if (Q_UNLIKELY(item->view)) { qWarning("QTableWidget: cannot insert an item that is already owned by another QTableWidget"); } else { item->view = this; diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index 676893ebf01..748d899dd06 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -3280,14 +3280,14 @@ QMimeData *QTreeWidget::mimeData(const QList items) const QList indexes; for (int i = 0; i < items.count(); ++i) { QTreeWidgetItem *item = items.at(i); - if (!item) { + if (Q_UNLIKELY(!item)) { qWarning("QTreeWidget::mimeData: Null-item passed"); return 0; } for (int c = 0; c < item->values.count(); ++c) { const QModelIndex index = indexFromItem(item, c); - if (!index.isValid()) { + if (Q_UNLIKELY(!index.isValid())) { qWarning() << "QTreeWidget::mimeData: No index associated with item :" << item; return 0; } diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp index 1563d020b6d..33067546234 100644 --- a/src/widgets/kernel/qaction.cpp +++ b/src/widgets/kernel/qaction.cpp @@ -45,7 +45,7 @@ #include #define QAPP_CHECK(functionName) \ - if (!qApp) { \ + if (Q_UNLIKELY(!qApp)) { \ qWarning("QAction: Initialize QApplication before calling '" functionName "'."); \ return; \ } diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 70c91b9aa42..e5d8960cf86 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1368,7 +1368,7 @@ int QApplication::colorSpec() void QApplication::setColorSpec(int spec) { - if (qApp) + if (Q_UNLIKELY(qApp)) qWarning("QApplication::setColorSpec: This function must be " "called before the QApplication object is created"); QApplicationPrivate::app_cspec = spec; @@ -2485,7 +2485,7 @@ bool QApplicationPrivate::isBlockedByModal(QWidget *widget) bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWindow) const { QWindow *unused = 0; - if (!window) { + if (Q_UNLIKELY(!window)) { qWarning().nospace() << "window == 0 passed."; return false; } @@ -3007,7 +3007,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) if (QApplicationPrivate::is_app_closing) return true; - if (receiver == 0) { // serious error + if (Q_UNLIKELY(!receiver)) { // serious error qWarning("QApplication::notify: Unexpected null receiver"); return true; } @@ -3256,7 +3256,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) QObject *obj = d->extraData->eventFilters.at(i); if (!obj) continue; - if (obj->d_func()->threadData != w->d_func()->threadData) { + if (Q_UNLIKELY(obj->d_func()->threadData != w->d_func()->threadData)) { qWarning("QApplication: Object event filter cannot be in a different thread."); continue; } diff --git a/src/widgets/kernel/qdesktopwidget.cpp b/src/widgets/kernel/qdesktopwidget.cpp index b88b3cc61d9..d82d0691bef 100644 --- a/src/widgets/kernel/qdesktopwidget.cpp +++ b/src/widgets/kernel/qdesktopwidget.cpp @@ -48,7 +48,7 @@ int QDesktopScreenWidget::screenNumber() const const QRect QDesktopWidget::screenGeometry(const QWidget *widget) const { - if (!widget) { + if (Q_UNLIKELY(!widget)) { qWarning("QDesktopWidget::screenGeometry(): Attempt " "to get the screen geometry of a null widget"); return QRect(); @@ -61,7 +61,7 @@ const QRect QDesktopWidget::screenGeometry(const QWidget *widget) const const QRect QDesktopWidget::availableGeometry(const QWidget *widget) const { - if (!widget) { + if (Q_UNLIKELY(!widget)) { qWarning("QDesktopWidget::availableGeometry(): Attempt " "to get the available geometry of a null widget"); return QRect(); diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index a7f9021c427..464d09cde14 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -945,7 +945,7 @@ void QFormLayoutPrivate::setItem(int row, QFormLayout::ItemRole role, QLayoutIte { const bool fullRow = role == QFormLayout::SpanningRole; const int column = role == QFormLayout::SpanningRole ? 1 : static_cast(role); - if (uint(row) >= uint(m_matrix.rowCount()) || uint(column) > 1U) { + if (Q_UNLIKELY(uint(row) >= uint(m_matrix.rowCount()) || uint(column) > 1U)) { qWarning("QFormLayoutPrivate::setItem: Invalid cell (%d, %d)", row, column); return; } @@ -953,7 +953,7 @@ void QFormLayoutPrivate::setItem(int row, QFormLayout::ItemRole role, QLayoutIte if (!item) return; - if (m_matrix(row, column)) { + if (Q_UNLIKELY(m_matrix(row, column))) { qWarning("QFormLayoutPrivate::setItem: Cell (%d, %d) already occupied", row, column); return; } @@ -1000,7 +1000,7 @@ QLayoutItem* QFormLayoutPrivate::replaceAt(int index, QLayoutItem *newitem) if (!newitem) return 0; const int storageIndex = storageIndexFromLayoutItem(m_matrix, m_things.value(index)); - if (storageIndex == -1) { + if (Q_UNLIKELY(storageIndex == -1)) { // ### Qt6 - fix warning too when this class becomes public qWarning("QFormLayoutPrivate::replaceAt: Invalid index %d", index); return 0; @@ -1414,7 +1414,7 @@ QLayoutItem *QFormLayout::takeAt(int index) Q_D(QFormLayout); const int storageIndex = storageIndexFromLayoutItem(d->m_matrix, d->m_things.value(index)); - if (storageIndex == -1) { + if (Q_UNLIKELY(storageIndex == -1)) { qWarning("QFormLayout::takeAt: Invalid index %d", index); return 0; } diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp index 51cffc6321b..2bf5eece647 100644 --- a/src/widgets/kernel/qgesturemanager.cpp +++ b/src/widgets/kernel/qgesturemanager.cpp @@ -117,7 +117,7 @@ QGestureManager::~QGestureManager() Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *recognizer) { QGesture *dummy = recognizer->create(0); - if (!dummy) { + if (Q_UNLIKELY(!dummy)) { qWarning("QGestureManager::registerGestureRecognizer: " "the recognizer fails to create a gesture object, skipping registration."); return Qt::GestureType(0); @@ -640,17 +640,17 @@ void QGestureManager::deliverEvents(const QSet &gestures, Q_ASSERT(gestureType != Qt::CustomGesture); Q_UNUSED(gestureType); - if (target) { + if (Q_UNLIKELY(!target)) { + qCDebug(lcGestureManager) << "QGestureManager::deliverEvent: could not find the target for gesture" + << gesture->gestureType(); + qWarning("QGestureManager::deliverEvent: could not find the target for gesture"); + undeliveredGestures->insert(gesture); + } else { if (gesture->state() == Qt::GestureStarted) { startedGestures.insert(gesture); } else { normalStartedGestures[target].append(gesture); } - } else { - qCDebug(lcGestureManager) << "QGestureManager::deliverEvent: could not find the target for gesture" - << gesture->gestureType(); - qWarning("QGestureManager::deliverEvent: could not find the target for gesture"); - undeliveredGestures->insert(gesture); } } diff --git a/src/widgets/kernel/qgridlayout.cpp b/src/widgets/kernel/qgridlayout.cpp index 85898ae86c7..f3272731d96 100644 --- a/src/widgets/kernel/qgridlayout.cpp +++ b/src/widgets/kernel/qgridlayout.cpp @@ -557,9 +557,9 @@ void QGridLayoutPrivate::add(QGridBox *box, int row, int col) void QGridLayoutPrivate::add(QGridBox *box, int row1, int row2, int col1, int col2) { - if (row2 >= 0 && row2 < row1) + if (Q_UNLIKELY(row2 >= 0 && row2 < row1)) qWarning("QGridLayout: Multi-cell fromRow greater than toRow"); - if (col2 >= 0 && col2 < col1) + if (Q_UNLIKELY(col2 >= 0 && col2 < col1)) qWarning("QGridLayout: Multi-cell fromCol greater than toCol"); if (row1 == row2 && col1 == col2) { add(box, row1, col1); @@ -1435,7 +1435,7 @@ void QGridLayout::addWidget(QWidget *widget, int row, int column, Qt::Alignment Q_D(QGridLayout); if (!d->checkWidget(widget)) return; - if (row < 0 || column < 0) { + if (Q_UNLIKELY(row < 0 || column < 0)) { qWarning("QGridLayout: Cannot add %s/%s to %s/%s at row %d column %d", widget->metaObject()->className(), widget->objectName().toLocal8Bit().data(), metaObject()->className(), objectName().toLocal8Bit().data(), row, column); diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index b6d87dc17e3..eec60b14d06 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -129,7 +129,7 @@ QLayout::QLayout(QLayoutPrivate &dd, QLayout *lay, QWidget *w) if (lay) { lay->addItem(this); } else if (w) { - if (w->layout()) { + if (Q_UNLIKELY(w->layout())) { qWarning("QLayout: Attempting to add QLayout \"%ls\" to %s \"%ls\", which" " already has a layout", qUtf16Printable(QObject::objectName()), w->metaObject()->className(), @@ -469,7 +469,7 @@ QWidget *QLayout::parentWidget() const if (!d->topLevel) { if (parent()) { QLayout *parentLayout = qobject_cast(parent()); - if (!parentLayout) { + if (Q_UNLIKELY(!parentLayout)) { qWarning("QLayout::parentWidget: A layout can only have another layout as a parent."); return 0; } @@ -776,7 +776,7 @@ QLayout::~QLayout() */ void QLayout::addChildLayout(QLayout *l) { - if (l->parent()) { + if (Q_UNLIKELY(l->parent())) { qWarning("QLayout::addChildLayout: layout \"%ls\" already has a parent", qUtf16Printable(l->objectName())); return; @@ -826,7 +826,7 @@ void QLayoutPrivate::reparentChildWidgets(QWidget *mw) if (QWidget *w = item->widget()) { QWidget *pw = w->parentWidget(); #ifdef QT_DEBUG - if (pw && pw != mw && layoutDebug()) { + if (Q_UNLIKELY(pw && pw != mw && layoutDebug())) { qWarning("QLayout::addChildLayout: widget %s \"%ls\" in wrong parent; moved to correct parent", w->metaObject()->className(), qUtf16Printable(w->objectName())); } @@ -849,12 +849,12 @@ void QLayoutPrivate::reparentChildWidgets(QWidget *mw) bool QLayoutPrivate::checkWidget(QWidget *widget) const { Q_Q(const QLayout); - if (!widget) { + if (Q_UNLIKELY(!widget)) { qWarning("QLayout: Cannot add a null widget to %s/%ls", q->metaObject()->className(), qUtf16Printable(q->objectName())); return false; } - if (widget == q->parentWidget()) { + if (Q_UNLIKELY(widget == q->parentWidget())) { qWarning("QLayout: Cannot add parent widget %s/%ls to its child layout %s/%ls", widget->metaObject()->className(), qUtf16Printable(widget->objectName()), q->metaObject()->className(), qUtf16Printable(q->objectName())); @@ -870,12 +870,12 @@ bool QLayoutPrivate::checkWidget(QWidget *widget) const bool QLayoutPrivate::checkLayout(QLayout *otherLayout) const { Q_Q(const QLayout); - if (!otherLayout) { + if (Q_UNLIKELY(!otherLayout)) { qWarning("QLayout: Cannot add a null layout to %s/%ls", q->metaObject()->className(), qUtf16Printable(q->objectName())); return false; } - if (otherLayout == q) { + if (Q_UNLIKELY(otherLayout == q)) { qWarning("QLayout: Cannot add layout %s/%ls to itself", q->metaObject()->className(), qUtf16Printable(q->objectName())); return false; @@ -902,7 +902,7 @@ void QLayout::addChildWidget(QWidget *w) QLayout *l = pw->layout(); if (l && removeWidgetRecursively(l, w)) { #ifdef QT_DEBUG - if (layoutDebug()) + if (Q_UNLIKELY(layoutDebug())) qWarning("QLayout::addChildWidget: %s \"%ls\" is already in a layout; moved to new layout", w->metaObject()->className(), qUtf16Printable(w->objectName())); #endif @@ -910,7 +910,7 @@ void QLayout::addChildWidget(QWidget *w) } if (pw && mw && pw != mw) { #ifdef QT_DEBUG - if (layoutDebug()) + if (Q_UNLIKELY(layoutDebug())) qWarning("QLayout::addChildWidget: %s \"%ls\" in wrong parent; moved to correct parent", w->metaObject()->className(), qUtf16Printable(w->objectName())); #endif @@ -1064,7 +1064,7 @@ bool QLayout::activate() if (d->activated) return false; QWidget *mw = static_cast(parent()); - if (mw == 0) { + if (Q_UNLIKELY(!mw)) { qWarning("QLayout::activate: %s \"%ls\" does not have a main widget", metaObject()->className(), qUtf16Printable(objectName())); return false; diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index 3a4a3a0d632..1522b065a7a 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -740,7 +740,7 @@ void QOpenGLWidgetPrivate::initialize() // texture usable by the underlying window's backingstore. QWidget *tlw = q->window(); QOpenGLContext *shareContext = get(tlw)->shareContext(); - if (!shareContext) { + if (Q_UNLIKELY(!shareContext)) { qWarning("QOpenGLWidget: Cannot be used without a context shared with the toplevel."); return; } @@ -756,7 +756,7 @@ void QOpenGLWidgetPrivate::initialize() ctx->setShareContext(shareContext); ctx->setFormat(requestedFormat); ctx->setScreen(shareContext->screen()); - if (!ctx->create()) { + if (Q_UNLIKELY(!ctx->create())) { qWarning("QOpenGLWidget: Failed to create context"); return; } @@ -782,7 +782,7 @@ void QOpenGLWidgetPrivate::initialize() surface->setScreen(ctx->screen()); surface->create(); - if (!ctx->makeCurrent(surface)) { + if (Q_UNLIKELY(!ctx->makeCurrent(surface))) { qWarning("QOpenGLWidget: Failed to make context current"); return; } @@ -915,10 +915,10 @@ QOpenGLWidget::QOpenGLWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(*(new QOpenGLWidgetPrivate), parent, f) { Q_D(QOpenGLWidget); - if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RasterGLSurface)) - d->setRenderToTexture(); - else + if (Q_UNLIKELY(!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RasterGLSurface))) qWarning("QOpenGLWidget is not supported on this platform."); + else + d->setRenderToTexture(); } /*! @@ -984,7 +984,7 @@ void QOpenGLWidget::setFormat(const QSurfaceFormat &format) { Q_UNUSED(format); Q_D(QOpenGLWidget); - if (d->initialized) { + if (Q_UNLIKELY(d->initialized)) { qWarning("QOpenGLWidget: Already initialized, setting the format has no effect"); return; } diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index c08c4eeb329..55b57c5c57c 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE #define QAPP_CHECK(functionName) \ - if (!qApp) { \ + if (Q_UNLIKELY(!qApp)) { \ qWarning("QShortcut: Initialize QApplication before calling '" functionName "'."); \ return; \ } @@ -410,7 +410,7 @@ public: void QShortcutPrivate::redoGrab(QShortcutMap &map) { Q_Q(QShortcut); - if (!parent) { + if (Q_UNLIKELY(!parent)) { qWarning("QShortcut: No widget parent defined"); return; } diff --git a/src/widgets/kernel/qstackedlayout.cpp b/src/widgets/kernel/qstackedlayout.cpp index 957b6f09b56..b76e92bc355 100644 --- a/src/widgets/kernel/qstackedlayout.cpp +++ b/src/widgets/kernel/qstackedlayout.cpp @@ -57,7 +57,7 @@ QLayoutItem* QStackedLayoutPrivate::replaceAt(int idx, QLayoutItem *newitem) if (idx < 0 || idx >= list.size() || !newitem) return 0; QWidget *wdg = newitem->widget(); - if (!wdg) { + if (Q_UNLIKELY(!wdg)) { qWarning("QStackedLayout::replaceAt: Only widgets can be added"); return 0; } @@ -367,7 +367,7 @@ int QStackedLayout::currentIndex() const void QStackedLayout::setCurrentWidget(QWidget *widget) { int index = indexOf(widget); - if (index == -1) { + if (Q_UNLIKELY(index == -1)) { qWarning("QStackedLayout::setCurrentWidget: Widget %p not contained in stack", widget); return; } @@ -420,12 +420,12 @@ int QStackedLayout::count() const void QStackedLayout::addItem(QLayoutItem *item) { QWidget *widget = item->widget(); - if (widget) { - addWidget(widget); - delete item; - } else { + if (Q_UNLIKELY(!widget)) { qWarning("QStackedLayout::addItem: Only widgets can be added"); + return; } + addWidget(widget); + delete item; } /*! diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp index 51bf6e46843..39a58d60dcd 100644 --- a/src/widgets/kernel/qtooltip.cpp +++ b/src/widgets/kernel/qtooltip.cpp @@ -264,12 +264,12 @@ void QTipLabel::hideTipImmediately() void QTipLabel::setTipRect(QWidget *w, const QRect &r) { - if (!r.isNull() && !w) + if (Q_UNLIKELY(!r.isNull() && !w)) { qWarning("QToolTip::setTipRect: Cannot pass null widget if rect is set"); - else{ - widget = w; - rect = r; + return; } + widget = w; + rect = r; } void QTipLabel::timerEvent(QTimerEvent *e) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 0f580f7369c..e8169d0bd1c 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1528,7 +1528,7 @@ QWidget::~QWidget() d->data.in_destructor = true; #if defined (QT_CHECK_STATE) - if (paintingActive()) + if (Q_UNLIKELY(paintingActive())) qWarning("QWidget: %s (%s) deleted while being painted", className(), name()); #endif @@ -3267,7 +3267,7 @@ void QWidget::addActions(QList actions) */ void QWidget::insertAction(QAction *before, QAction *action) { - if(!action) { + if (Q_UNLIKELY(!action)) { qWarning("QWidget::insertAction: Attempt to insert null action"); return; } @@ -3913,7 +3913,7 @@ bool QWidgetPrivate::setMinimumSize_helper(int &minw, int &minh) mw = 0; if (mh == QWIDGETSIZE_MAX) mh = 0; - if (minw > QWIDGETSIZE_MAX || minh > QWIDGETSIZE_MAX) { + if (Q_UNLIKELY(minw > QWIDGETSIZE_MAX || minh > QWIDGETSIZE_MAX)) { qWarning("QWidget::setMinimumSize: (%s/%s) " "The largest allowed size is (%d,%d)", q->objectName().toLocal8Bit().data(), q->metaObject()->className(), QWIDGETSIZE_MAX, @@ -3921,7 +3921,7 @@ bool QWidgetPrivate::setMinimumSize_helper(int &minw, int &minh) minw = mw = qMin(minw, QWIDGETSIZE_MAX); minh = mh = qMin(minh, QWIDGETSIZE_MAX); } - if (minw < 0 || minh < 0) { + if (Q_UNLIKELY(minw < 0 || minh < 0)) { qWarning("QWidget::setMinimumSize: (%s/%s) Negative sizes (%d,%d) " "are not possible", q->objectName().toLocal8Bit().data(), q->metaObject()->className(), minw, minh); @@ -3995,7 +3995,7 @@ void QWidget::setMinimumSize(int minw, int minh) bool QWidgetPrivate::setMaximumSize_helper(int &maxw, int &maxh) { Q_Q(QWidget); - if (maxw > QWIDGETSIZE_MAX || maxh > QWIDGETSIZE_MAX) { + if (Q_UNLIKELY(maxw > QWIDGETSIZE_MAX || maxh > QWIDGETSIZE_MAX)) { qWarning("QWidget::setMaximumSize: (%s/%s) " "The largest allowed size is (%d,%d)", q->objectName().toLocal8Bit().data(), q->metaObject()->className(), QWIDGETSIZE_MAX, @@ -4003,7 +4003,7 @@ bool QWidgetPrivate::setMaximumSize_helper(int &maxw, int &maxh) maxw = qMin(maxw, QWIDGETSIZE_MAX); maxh = qMin(maxh, QWIDGETSIZE_MAX); } - if (maxw < 0 || maxh < 0) { + if (Q_UNLIKELY(maxw < 0 || maxh < 0)) { qWarning("QWidget::setMaximumSize: (%s/%s) Negative sizes (%d,%d) " "are not possible", q->objectName().toLocal8Bit().data(), q->metaObject()->className(), maxw, maxh); @@ -5104,12 +5104,12 @@ void QWidget::render(QPaintDevice *target, const QPoint &targetOffset, void QWidget::render(QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion, RenderFlags renderFlags) { - if (!painter) { + if (Q_UNLIKELY(!painter)) { qWarning("QWidget::render: Null pointer to painter"); return; } - if (!painter->isActive()) { + if (Q_UNLIKELY(!painter->isActive())) { qWarning("QWidget::render: Cannot render with an inactive painter"); return; } @@ -5498,7 +5498,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP if (!toBePainted.isEmpty()) { if (!onScreen || alsoOnScreen) { //update the "in paint event" flag - if (q->testAttribute(Qt::WA_WState_InPaintEvent)) + if (Q_UNLIKELY(q->testAttribute(Qt::WA_WState_InPaintEvent))) qWarning("QWidget::repaint: Recursive repaint detected"); q->setAttribute(Qt::WA_WState_InPaintEvent); @@ -5605,7 +5605,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP setSystemClip(pdev, QRegion()); } q->setAttribute(Qt::WA_WState_InPaintEvent, false); - if (q->paintingActive()) + if (Q_UNLIKELY(q->paintingActive())) qWarning("QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent"); if (paintEngine && paintEngine->autoDestruct()) { @@ -5654,7 +5654,7 @@ void QWidgetPrivate::sendPaintEvent(const QRegion &toBePainted) void QWidgetPrivate::render(QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags) { - if (!target) { + if (Q_UNLIKELY(!target)) { qWarning("QWidget::render: null pointer to paint device"); return; } @@ -5788,7 +5788,7 @@ QRectF QWidgetEffectSourcePrivate::boundingRect(Qt::CoordinateSystem system) con if (system != Qt::DeviceCoordinates) return m_widget->rect(); - if (!context) { + if (Q_UNLIKELY(!context)) { // Device coordinates without context not yet supported. qWarning("QGraphicsEffectSource::boundingRect: Not yet implemented, lacking device context"); return QRectF(); @@ -5820,7 +5820,7 @@ QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint * QGraphicsEffect::PixmapPadMode mode) const { const bool deviceCoordinates = (system == Qt::DeviceCoordinates); - if (!context && deviceCoordinates) { + if (Q_UNLIKELY(!context && deviceCoordinates)) { // Device coordinates without context not yet supported. qWarning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context"); return QPixmap(); @@ -6353,7 +6353,7 @@ void QWidget::setFocusProxy(QWidget * w) return; for (QWidget* fp = w; fp; fp = fp->focusProxy()) { - if (fp == this) { + if (Q_UNLIKELY(fp == this)) { qWarning("QWidget: %s (%s) already in focus proxy chain", metaObject()->className(), objectName().toLocal8Bit().constData()); return; } @@ -6867,7 +6867,7 @@ void QWidget::setTabOrder(QWidget* first, QWidget *second) if (!first || !second || first->focusPolicy() == Qt::NoFocus || second->focusPolicy() == Qt::NoFocus) return; - if (first->window() != second->window()) { + if (Q_UNLIKELY(first->window() != second->window())) { qWarning("QWidget::setTabOrder: 'first' and 'second' must be in the same window"); return; } @@ -10024,12 +10024,12 @@ QLayout *QWidget::layout() const void QWidget::setLayout(QLayout *l) { - if (!l) { + if (Q_UNLIKELY(!l)) { qWarning("QWidget::setLayout: Cannot set layout to 0"); return; } if (layout()) { - if (layout() != l) + if (Q_UNLIKELY(layout() != l)) qWarning("QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", which already has a" " layout", l->objectName().toLocal8Bit().data(), metaObject()->className(), objectName().toLocal8Bit().data()); @@ -11374,7 +11374,7 @@ void QWidgetPrivate::setWindowModified_helper() return; bool on = q->testAttribute(Qt::WA_WindowModified); if (!platformWindow->setWindowModified(on)) { - if (!q->windowTitle().contains(QLatin1String("[*]")) && on) + if (Q_UNLIKELY(on && !q->windowTitle().contains(QLatin1String("[*]")))) qWarning("QWidget::setWindowModified: The window title does not contain a '[*]' placeholder"); setWindowTitle_helper(q->windowTitle()); setWindowIconText_helper(q->windowIconText()); @@ -12124,7 +12124,7 @@ QOpenGLContext *QWidgetPrivate::shareContext() const #ifdef QT_NO_OPENGL return 0; #else - if (!extra || !extra->topextra || !extra->topextra->window) { + if (Q_UNLIKELY(!extra || !extra->topextra || !extra->topextra->window)) { qWarning("Asking for share context for widget that does not have a window handle"); return 0; } diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index 55b8513072d..90311b0f0a5 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -1554,7 +1554,7 @@ void QWidgetPrivate::repaint_sys(const QRegion &rgn) QWidgetBackingStore::unflushPaint(q, toBePainted); #endif - if (q->paintingActive()) + if (Q_UNLIKELY(q->paintingActive())) qWarning("QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent"); } diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index e3c40ef95e3..cce667ffbf6 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -798,7 +798,7 @@ void QWidgetWindow::handleDragLeaveEvent(QDragLeaveEvent *event) void QWidgetWindow::handleDropEvent(QDropEvent *event) { - if (m_dragTarget.isNull()) { + if (Q_UNLIKELY(m_dragTarget.isNull())) { qWarning() << Q_FUNC_INFO << m_widget << ": No drag target set."; event->ignore(); return; diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp index 3885431b059..98a3330822c 100644 --- a/src/widgets/kernel/qwindowcontainer.cpp +++ b/src/widgets/kernel/qwindowcontainer.cpp @@ -193,7 +193,7 @@ QWindowContainer::QWindowContainer(QWindow *embeddedWindow, QWidget *parent, Qt: : QWidget(*new QWindowContainerPrivate, parent, flags) { Q_D(QWindowContainer); - if (!embeddedWindow) { + if (Q_UNLIKELY(!embeddedWindow)) { qWarning("QWindowContainer: embedded window cannot be null"); return; } diff --git a/src/widgets/styles/qandroidstyle.cpp b/src/widgets/styles/qandroidstyle.cpp index 4489f36ab79..9a0e4ba32a7 100644 --- a/src/widgets/styles/qandroidstyle.cpp +++ b/src/widgets/styles/qandroidstyle.cpp @@ -84,7 +84,7 @@ QAndroidStyle::QAndroidStyle() ++objectIterator) { QString key = objectIterator.key(); QJsonValue value = objectIterator.value(); - if (!value.isObject()) { + if (Q_UNLIKELY(!value.isObject())) { qWarning("Style.json structure is unrecognized."); continue; } diff --git a/src/widgets/styles/qdrawutil.cpp b/src/widgets/styles/qdrawutil.cpp index 2a4d3924135..d50f04bbb8d 100644 --- a/src/widgets/styles/qdrawutil.cpp +++ b/src/widgets/styles/qdrawutil.cpp @@ -87,7 +87,7 @@ void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2, const QPalette &pal, bool sunken, int lineWidth, int midLineWidth) { - if (!(p && lineWidth >= 0 && midLineWidth >= 0)) { + if (Q_UNLIKELY(!p || lineWidth < 0 || midLineWidth < 0)) { qWarning("qDrawShadeLine: Invalid parameters"); return; } @@ -203,7 +203,7 @@ void qDrawShadeRect(QPainter *p, int x, int y, int w, int h, { if (w == 0 || h == 0) return; - if (! (w > 0 && h > 0 && lineWidth >= 0 && midLineWidth >= 0)) { + if (Q_UNLIKELY(w < 0 || h < 0 || lineWidth < 0 || midLineWidth < 0)) { qWarning("qDrawShadeRect: Invalid parameters"); return; } @@ -303,7 +303,7 @@ void qDrawShadePanel(QPainter *p, int x, int y, int w, int h, { if (w == 0 || h == 0) return; - if (!(w > 0 && h > 0 && lineWidth >= 0)) { + if (Q_UNLIKELY(w < 0 || h < 0 || lineWidth < 0)) { qWarning("qDrawShadePanel: Invalid parameters"); } QColor shade = pal.dark().color(); @@ -509,7 +509,7 @@ void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &c, { if (w == 0 || h == 0) return; - if (!(w > 0 && h > 0 && lineWidth >= 0)) { + if (Q_UNLIKELY(w < 0 || h < 0 || lineWidth < 0)) { qWarning("qDrawPlainRect: Invalid parameters"); } QPen oldPen = p->pen(); diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 0c255f231eb..40cca059a86 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -1547,7 +1547,7 @@ QVector QStyleSheetStyle::styleRules(const QObject *obj) const if (ss.startsWith(QLatin1String("file:///"))) ss.remove(0, 8); parser.init(ss, qApp->styleSheet() != ss); - if (!parser.parse(&appSs)) + if (Q_UNLIKELY(!parser.parse(&appSs))) qWarning("Could not parse application stylesheet"); appSs.origin = StyleSheetOrigin_Inline; appSs.depth = 1; @@ -1569,7 +1569,7 @@ QVector QStyleSheetStyle::styleRules(const QObject *obj) const parser.init(styleSheet); if (!parser.parse(&ss)) { parser.init(QLatin1String("* {") + styleSheet + QLatin1Char('}')); - if (!parser.parse(&ss)) + if (Q_UNLIKELY(!parser.parse(&ss))) qWarning("Could not parse stylesheet of object %p", o); } ss.origin = StyleSheetOrigin_Inline; @@ -2515,12 +2515,12 @@ void QStyleSheetStyle::setProperties(QWidget *w) const QMetaObject *metaObject = w->metaObject(); int index = metaObject->indexOfProperty(property.toLatin1()); - if (index == -1) { + if (Q_UNLIKELY(index == -1)) { qWarning() << w << " does not have a property named " << property; continue; } const QMetaProperty metaProperty = metaObject->property(index); - if (!metaProperty.isWritable() || !metaProperty.isDesignable()) { + if (Q_UNLIKELY(!metaProperty.isWritable() || !metaProperty.isDesignable())) { qWarning() << w << " cannot design property named " << property; continue; } diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index a7a0830fb92..3be5ae35249 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -2471,12 +2471,12 @@ bool QWindowsVistaStylePrivate::initTreeViewTheming() return true; m_treeViewHelper = createTreeViewHelperWindow(); - if (!m_treeViewHelper) { + if (Q_UNLIKELY(!m_treeViewHelper)) { qWarning("%s: Unable to create the treeview helper window.", Q_FUNC_INFO); return false; } const HRESULT hr = QWindowsXPStylePrivate::pSetWindowTheme(m_treeViewHelper, L"explorer", NULL); - if (hr != S_OK) { + if (Q_UNLIKELY(hr != S_OK)) { qErrnoWarning("%s: SetWindowTheme() failed.", Q_FUNC_INFO); return false; } diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index 0b332133781..8bd4f69d20f 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -337,14 +337,14 @@ void QWindowsXPStylePrivate::cleanupHandleMap() HTHEME QWindowsXPStylePrivate::createTheme(int theme, HWND hwnd) { - if (theme < 0 || theme >= NThemes || !hwnd) { + if (Q_UNLIKELY(theme < 0 || theme >= NThemes || !hwnd)) { qWarning("%s: Invalid parameters #%d, %p", Q_FUNC_INFO, theme, hwnd); return 0; } if (!m_themes[theme]) { const wchar_t *name = themeNames[theme]; m_themes[theme] = pOpenThemeData(hwnd, name); - if (!m_themes[theme]) + if (Q_UNLIKELY(!m_themes[theme])) qErrnoWarning("%s: OpenThemeData() failed for theme %d (%s).", Q_FUNC_INFO, theme, qPrintable(themeName(theme))); } @@ -504,13 +504,13 @@ HBITMAP QWindowsXPStylePrivate::buffer(int w, int h) GdiFlush(); nullBitmap = (HBITMAP)SelectObject(bufferDC, bufferBitmap); - if (!bufferBitmap) { + if (Q_UNLIKELY(!bufferBitmap)) { qErrnoWarning("QWindowsXPStylePrivate::buffer(%dx%d), CreateDIBSection() failed.", w, h); bufferW = 0; bufferH = 0; return 0; } - if (!bufferPixels) { + if (Q_UNLIKELY(!bufferPixels)) { qErrnoWarning("QWindowsXPStylePrivate::buffer(%dx%d), CreateDIBSection() did not allocate pixel data.", w, h); bufferW = 0; bufferH = 0;