diff options
author | Axel Spoerl <axel.spoerl@qt.io> | 2023-11-08 16:50:35 +0100 |
---|---|---|
committer | Axel Spoerl <axel.spoerl@qt.io> | 2023-11-09 14:59:41 +0000 |
commit | c93ab8c2a015b40b9a487ed9f23a72aebea8d52a (patch) | |
tree | 3aab74d5cda5c14ebe3f9bedf81767996de4e8dc /src/widgets/widgets/qdockwidget.cpp | |
parent | c02f8b9d4d9a6578bb2017bafbb963d09641383f (diff) |
QDockWidget: Remove "group" bool trap
The unplug() and startDrag() functions of QMainWindowLayout and
QDockWidget used a boolean argument specifying whether a single dock
widget or a group of dock widgets should be unplugged. The argument
defaulted to true.
That has lead to inconsistent unplug operations, broken item_lists and
crashes, especially when the methods were called without an argument.
To improve code readability, replace bool trap with a meaningful
enum. Remove default arguments, in order to force explicit calls.
This patch does not change behavior, it is just carved out to
facilitate reviews.
Task-number: QTBUG-118578
Task-number: QTBUG-118579
Pick-to: 6.6 6.5
Change-Id: I50341b055f0bb76c2797b2fb1126a10de1fee7dd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/widgets/qdockwidget.cpp')
-rw-r--r-- | src/widgets/widgets/qdockwidget.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index 8453a309c8..c225c1bdfd 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -750,7 +750,7 @@ void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca) tabbed widgets, and false if the dock widget should always be dragged alone. */ -void QDockWidgetPrivate::startDrag(bool group) +void QDockWidgetPrivate::startDrag(DragScope scope) { Q_Q(QDockWidget); @@ -764,7 +764,7 @@ void QDockWidgetPrivate::startDrag(bool group) bool wasFloating = q->isFloating(); #endif - state->widgetItem = layout->unplug(q, group); + state->widgetItem = layout->unplug(q, scope); if (state->widgetItem == nullptr) { /* Dock widget has a QMainWindow parent, but was never inserted with QMainWindow::addDockWidget, so the QMainWindowLayout has no @@ -978,7 +978,7 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event) } else #endif { - startDrag(); + startDrag(DragScope::Group); q->grabMouse(); ret = true; } @@ -1089,7 +1089,7 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event) break; state->ctrlDrag = (event->modifiers() & Qt::ControlModifier) || (!hasFeature(this, QDockWidget::DockWidgetMovable) && q->isFloating()); - startDrag(); + startDrag(DragScope::Group); break; case QEvent::NonClientAreaMouseMove: if (state == nullptr || !state->dragging) |