diff options
Diffstat (limited to 'src/widgets/widgets/qmdisubwindow.cpp')
-rw-r--r-- | src/widgets/widgets/qmdisubwindow.cpp | 63 |
1 files changed, 31 insertions, 32 deletions
diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index 14aeb73baf..610cb1201f 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWidgets module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -569,10 +575,7 @@ void ControllerWidget::setControlVisible(QMdiSubWindowPrivate::WindowStateAction if (subControl == QStyle::SC_None) return; - if (visible && !(visibleControls & subControl)) - visibleControls |= subControl; - else if (!visible && (visibleControls & subControl)) - visibleControls &= ~subControl; + visibleControls.setFlag(subControl, visible && !(visibleControls & subControl)); } /* @@ -1000,7 +1003,9 @@ void QMdiSubWindowPrivate::removeBaseWidget() q->setWindowModified(false); } lastChildWindowTitle.clear(); - baseWidget->setParent(0); + // QTBUG-47993: parent widget can be reset before this call + if (baseWidget->parentWidget() == q) + baseWidget->setParent(0); baseWidget = 0; isWidgetHiddenByUs = false; } @@ -2204,8 +2209,8 @@ void QMdiSubWindowPrivate::setSizeGrip(QSizeGrip *newSizeGrip) void QMdiSubWindowPrivate::setSizeGripVisible(bool visible) const { // See if we can find any size grips - QList<QSizeGrip *> sizeGrips = q_func()->findChildren<QSizeGrip *>(); - foreach (QSizeGrip *grip, sizeGrips) + const QList<QSizeGrip *> sizeGrips = q_func()->findChildren<QSizeGrip *>(); + for (QSizeGrip *grip : sizeGrips) grip->setVisible(visible); } @@ -2307,7 +2312,7 @@ void QMdiSubWindow::setWidget(QWidget *widget) return; } - if (widget == d->baseWidget) { + if (Q_UNLIKELY(widget == d->baseWidget)) { qWarning("QMdiSubWindow::setWidget: widget is already set"); return; } @@ -2409,10 +2414,7 @@ bool QMdiSubWindow::isShaded() const void QMdiSubWindow::setOption(SubWindowOption option, bool on) { Q_D(QMdiSubWindow); - if (on && !(d->options & option)) - d->options |= option; - else if (!on && (d->options & option)) - d->options &= ~option; + d->options.setFlag(option, on); #ifndef QT_NO_RUBBERBAND if ((option & (RubberBandResize | RubberBandMove)) && !on && d->isInRubberBandMode) @@ -2505,7 +2507,7 @@ void QMdiSubWindow::setKeyboardPageStep(int step) void QMdiSubWindow::setSystemMenu(QMenu *systemMenu) { Q_D(QMdiSubWindow); - if (systemMenu && systemMenu == d->systemMenu) { + if (Q_UNLIKELY(systemMenu && systemMenu == d->systemMenu)) { qWarning("QMdiSubWindow::setSystemMenu: system menu is already set"); return; } @@ -2653,7 +2655,7 @@ void QMdiSubWindow::showShaded() resize(d->internalMinimumSize); // Hide the internal widget if not already hidden by the user. - if (d->baseWidget && !d->baseWidget->isHidden()) { + if (d->baseWidget && !d->baseWidget->isHidden() && !(windowFlags() & Qt::FramelessWindowHint)) { d->baseWidget->hide(); d->isWidgetHiddenByUs = true; } @@ -3164,10 +3166,7 @@ void QMdiSubWindow::paintEvent(QPaintEvent *paintEvent) QStyleOptionFrame frameOptions; frameOptions.initFrom(this); frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, this); - if (d->isActive) - frameOptions.state |= QStyle::State_Active; - else - frameOptions.state &= ~QStyle::State_Active; + frameOptions.state.setFlag(QStyle::State_Active, d->isActive); // ### Ensure that we do not require setting the cliprect for 4.4 if (!isMinimized() && !d->hasBorder(d->cachedStyleOptions)) |