diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index e6656e360ac..2b6e1eebd03 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -436,20 +436,6 @@ private: alignas(void *) char prealloc_[3 * sizeof(void *) + 3 * sizeof(QMetaType)]; }; -class QBoolBlocker -{ - Q_DISABLE_COPY_MOVE(QBoolBlocker) -public: - Q_NODISCARD_CTOR explicit QBoolBlocker(bool &b, bool value = true) - : block(b), reset(b) - { block = value; } - inline ~QBoolBlocker() { block = reset; } - -private: - bool █ - bool reset; -}; - struct QAbstractDynamicMetaObject; struct Q_CORE_EXPORT QDynamicMetaObjectData { diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h index 8d5d239c6e7..b52389f3907 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h @@ -94,7 +94,7 @@ public: // Set 'blockSendPostedEvents' to true if you _really_ need // to make sure that qt events are not posted while calling // low-level cocoa functions (like beginModalForWindow). And - // use a QBoolBlocker to be safe: + // use a QScopedValueRollback to be safe: bool blockSendPostedEvents; // The following variables help organizing modal sessions: QStack cocoaModalSessionStack; diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm index 0df2794554e..5ef7ca37efb 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm @@ -296,7 +296,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) d->interrupt = true; d->propagateInterrupt = false; }); - QBoolBlocker interruptBlocker(d->interrupt, false); + QScopedValueRollback interruptBlocker(d->interrupt, false); bool interruptLater = false; QtCocoaInterruptDispatcher::cancelInterruptLater(); @@ -342,7 +342,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) // interrupted. This is mostly an optimization, but it allow us to use // [NSApp run], which is the normal code path for cocoa applications. if (NSModalSession session = d->currentModalSession()) { - QBoolBlocker execGuard(d->currentExecIsNSAppRun, false); + QScopedValueRollback execGuard(d->currentExecIsNSAppRun, false); qCDebug(lcEventDispatcher) << "Running modal session" << session; while ([NSApp runModalSession:session] == NSModalResponseContinue && !d->interrupt) { qt_mac_waitForMoreEvents(NSModalPanelRunLoopMode); @@ -370,7 +370,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) } else { d->nsAppRunCalledByQt = true; - QBoolBlocker execGuard(d->currentExecIsNSAppRun, true); + QScopedValueRollback execGuard(d->currentExecIsNSAppRun, true); [NSApp run]; } retVal = true; @@ -562,7 +562,7 @@ void QCocoaEventDispatcherPrivate::ensureNSAppInitialized() // Stopping the application will still process runloop sources before // actually stopping, so we need to explicitly guard our sources from // doing anything, deferring their actions until later. - QBoolBlocker initializationGuard(initializingNSApplication, true); + QScopedValueRollback initializationGuard(initializingNSApplication, true); CFRunLoopPerformBlock(mainRunLoop(), kCFRunLoopCommonModes, ^{ qCDebug(lcEventDispatcher) << "NSApplication has been initialized; Stopping NSApp"; @@ -624,7 +624,7 @@ NSModalSession QCocoaEventDispatcherPrivate::currentModalSession() continue; ensureNSAppInitialized(); - QBoolBlocker block1(blockSendPostedEvents, true); + QScopedValueRollback block1(blockSendPostedEvents, true); info.nswindow = nswindow; [(NSWindow*) info.nswindow retain]; QRect rect = cocoaWindow->geometry(); diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm index 0eb53637dde..ba6bda0f8ca 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.mm +++ b/src/plugins/platforms/cocoa/qcocoascreen.mm @@ -84,7 +84,7 @@ void QCocoaScreen::updateScreens() qCInfo(lcQpaScreen) << "Skipping screen update, already updating"; return; } - QBoolBlocker recursionGuard(updatingScreens); + QScopedValueRollback recursionGuard(updatingScreens, true); uint32_t displayCount = 0; if (CGGetOnlineDisplayList(0, nullptr, &displayCount) != kCGErrorSuccess) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 8bcc200b57c..bad0e173713 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -215,7 +215,7 @@ void QCocoaWindow::setGeometry(const QRect &rectIn) { qCDebug(lcQpaWindow) << "QCocoaWindow::setGeometry" << window() << rectIn; - QBoolBlocker inSetGeometry(m_inSetGeometry, true); + QScopedValueRollback inSetGeometry(m_inSetGeometry, true); QRect rect = rectIn; // This means it is a call from QWindow::setFramePosition() and diff --git a/src/plugins/platforms/cocoa/qnsview_keys.mm b/src/plugins/platforms/cocoa/qnsview_keys.mm index aa224682d50..841024bc5f7 100644 --- a/src/plugins/platforms/cocoa/qnsview_keys.mm +++ b/src/plugins/platforms/cocoa/qnsview_keys.mm @@ -69,7 +69,7 @@ static bool sendAsShortcut(const KeyEvent &keyEvent, QWindow *window) QWindow *window = [self topLevelWindow]; // We will send a key event unless the input method handles it - QBoolBlocker sendKeyEventGuard(m_sendKeyEvent, true); + QScopedValueRollback sendKeyEventGuard(m_sendKeyEvent, true); // Assume we should send key events with text, unless told // otherwise by doCommandBySelector. diff --git a/src/plugins/platforms/cocoa/qnswindow.mm b/src/plugins/platforms/cocoa/qnswindow.mm index 18c5d105cd3..fb8a0eb2257 100644 --- a/src/plugins/platforms/cocoa/qnswindow.mm +++ b/src/plugins/platforms/cocoa/qnswindow.mm @@ -375,7 +375,7 @@ NSWindow *qnswindow_cast(NSWindow *window) - (void)miniaturize:(id)sender { - QBoolBlocker miniaturizeTracker(m_isMinimizing, true); + QScopedValueRollback miniaturizeTracker(m_isMinimizing, true); [super miniaturize:sender]; } diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 3a9bf6bea9f..55abd6dd04a 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -2258,7 +2258,7 @@ static QString msgUnableToSetGeometry(const QWindowsWindow *platformWindow, void QWindowsWindow::setGeometry(const QRect &rectIn) { - QBoolBlocker b(m_inSetgeometry); + QScopedValueRollback b(m_inSetgeometry, true); QRect rect = rectIn; // This means it is a call from QWindow::setFramePosition() and diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index e9a8b3efce4..7f99b9dc3d3 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -2885,7 +2885,7 @@ void QComboBox::hidePopup() if (d->hidingPopup) return; d->hidingPopup = true; - // can't use QBoolBlocker on a bitfield + // can't use QScopedValueRollback on a bitfield auto resetHidingPopup = qScopeGuard([d]{ d->hidingPopup = false; }); diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp index 0b6a4df41aa..74768a0eafe 100644 --- a/src/widgets/widgets/qdialogbuttonbox.cpp +++ b/src/widgets/widgets/qdialogbuttonbox.cpp @@ -189,7 +189,7 @@ void QDialogButtonBoxPrivate::layoutButtons() Q_Q(QDialogButtonBox); const int MacGap = 36 - 8; // 8 is the default gap between a widget and a spacer item - QBoolBlocker blocker(ignoreShowAndHide); + QScopedValueRollback blocker(ignoreShowAndHide, true); for (int i = buttonLayout->count() - 1; i >= 0; --i) { QLayoutItem *item = buttonLayout->takeAt(i); if (QWidget *widget = item->widget()) diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 0d86d51357b..8d5b3a8b792 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -1412,7 +1412,7 @@ void QMenuPrivate::activateCausedStack(const QList> &causedSta QAction::ActionEvent action_e, bool self) { Q_Q(QMenu); - // can't use QBoolBlocker here + // can't use QScopedValueRollback here const bool activationRecursionGuardReset = activationRecursionGuard; activationRecursionGuard = true; QPointer guard(q); diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp index 45f0c3895de..eec6befb092 100644 --- a/src/widgets/widgets/qsplitter.cpp +++ b/src/widgets/widgets/qsplitter.cpp @@ -805,7 +805,7 @@ QSplitterLayoutStruct *QSplitterPrivate::findWidget(QWidget *w) const void QSplitterPrivate::insertWidget_helper(int index, QWidget *widget, bool show) { Q_Q(QSplitter); - QBoolBlocker b(blockChildAdd); + QScopedValueRollback b(blockChildAdd, true); const bool needShow = show && shouldShowWidget(widget); if (widget->parentWidget() != q) widget->setParent(q); @@ -1145,7 +1145,7 @@ QWidget *QSplitter::replaceWidget(int index, QWidget *widget) return nullptr; } - QBoolBlocker b(d->blockChildAdd); + QScopedValueRollback b(d->blockChildAdd, true); const QRect geom = current->geometry(); const bool wasHidden = current->isHidden(); @@ -1310,7 +1310,7 @@ void QSplitter::setRubberBand(int pos) const int rBord = 3; // customizable? int hw = handleWidth(); if (!d->rubberBand) { - QBoolBlocker b(d->blockChildAdd); + QScopedValueRollback b(d->blockChildAdd, true); d->rubberBand = new QRubberBand(QRubberBand::Line, this); // For accessibility to identify this special widget. d->rubberBand->setObjectName("qt_rubberband"_L1);