diff options
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r-- | src/widgets/kernel/qaction.cpp | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 8 | ||||
-rw-r--r-- | src/widgets/kernel/qdesktopwidget.cpp | 4 | ||||
-rw-r--r-- | src/widgets/kernel/qformlayout.cpp | 8 | ||||
-rw-r--r-- | src/widgets/kernel/qgesturemanager.cpp | 14 | ||||
-rw-r--r-- | src/widgets/kernel/qgridlayout.cpp | 6 | ||||
-rw-r--r-- | src/widgets/kernel/qlayout.cpp | 22 | ||||
-rw-r--r-- | src/widgets/kernel/qopenglwidget.cpp | 14 | ||||
-rw-r--r-- | src/widgets/kernel/qshortcut.cpp | 4 | ||||
-rw-r--r-- | src/widgets/kernel/qstackedlayout.cpp | 12 | ||||
-rw-r--r-- | src/widgets/kernel/qtooltip.cpp | 8 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 38 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetbackingstore.cpp | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetwindow.cpp | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qwindowcontainer.cpp | 2 |
15 files changed, 73 insertions, 73 deletions
diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp index 1563d020b6..3306754623 100644 --- a/src/widgets/kernel/qaction.cpp +++ b/src/widgets/kernel/qaction.cpp @@ -45,7 +45,7 @@ #include <private/qmenu_p.h> #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 70c91b9aa4..e5d8960cf8 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 b88b3cc61d..d82d0691be 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 a7f9021c42..464d09cde1 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<int>(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 51cffc6321..2bf5eece64 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<QGesture *> &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 85898ae86c..f3272731d9 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 b6d87dc17e..eec60b14d0 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<QLayout*>(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<QWidget*>(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 3a4a3a0d63..1522b065a7 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 c08c4eeb32..55b57c5c57 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 957b6f09b5..b76e92bc35 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 51bf6e4684..39a58d60dc 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 0f580f7369..e8169d0bd1 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<QAction*> 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<int>(minw, QWIDGETSIZE_MAX); minh = mh = qMin<int>(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<int>(maxw, QWIDGETSIZE_MAX); maxh = qMin<int>(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 55b8513072..90311b0f0a 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 e3c40ef95e..cce667ffbf 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 3885431b05..98a3330822 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; } |