forked from qt-creator/qt-creator
Debugger: Avoid setParent(0) on QDockWidgets
This spells trouble as dock widgets which have a native window will assume they should be positioned relative to the outermost native window then. Change-Id: I5a8ce5870afacaabe26d4a2d7ac53ffee09328ed Task-number: QTCREATORBUG-15844 Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
@@ -79,20 +79,20 @@ DebuggerMainWindow::DebuggerMainWindow()
|
|||||||
|
|
||||||
DebuggerMainWindow::~DebuggerMainWindow()
|
DebuggerMainWindow::~DebuggerMainWindow()
|
||||||
{
|
{
|
||||||
// as we have to setParent(0) on dock widget that are not selected,
|
// We keep track of widgets for operations that haven't been activated, yet, and make sure we
|
||||||
// we keep track of all and make sure we don't leak any
|
// don't leak any.
|
||||||
foreach (const Perspective &perspective, m_perspectiveForPerspectiveId) {
|
foreach (const Perspective &perspective, m_perspectiveForPerspectiveId) {
|
||||||
foreach (const Perspective::Operation &operation, perspective.operations()) {
|
foreach (const Perspective::Operation &operation, perspective.operations()) {
|
||||||
if (operation.widget) {
|
if (operation.widget) {
|
||||||
// There are two possible states: Either addDockForWidget(widget) has
|
// There are two possible states: Either addDockForWidget(widget) has
|
||||||
// been on operation.widget (e.g. when the perspective gets activated)
|
// been called on an operation.widget (e.g. when the perspective gets
|
||||||
// for the first time, or not. In the first case we delete only the
|
// activated for the first time), or not. In the first case we don't
|
||||||
// widget, in the second case its parent, which is the dock.
|
// have to explicitly delete it as we have called setParent(this) on
|
||||||
if (QWidget *parent = operation.widget->parentWidget()) {
|
// it. In the second case, if the widget didn't have a parent before,
|
||||||
QTC_CHECK(qobject_cast<QDockWidget *>(parent));
|
// we have to delete it.
|
||||||
delete parent;
|
if (!operation.widget->parentWidget()) {
|
||||||
} else {
|
// These are from perspectives that were never activated and didn't
|
||||||
// These are from perspectives that never
|
// have a parent to begin with.
|
||||||
delete operation.widget;
|
delete operation.widget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -265,10 +265,10 @@ void DebuggerMainWindow::loadPerspectiveHelper(const QByteArray &perspectiveId,
|
|||||||
saveCurrentPerspective();
|
saveCurrentPerspective();
|
||||||
foreach (QDockWidget *dockWidget, m_dockForDockId) {
|
foreach (QDockWidget *dockWidget, m_dockForDockId) {
|
||||||
QTC_ASSERT(dockWidget, continue);
|
QTC_ASSERT(dockWidget, continue);
|
||||||
|
dockWidget->setFloating(false);
|
||||||
|
dockWidget->setParent(this);
|
||||||
removeDockWidget(dockWidget);
|
removeDockWidget(dockWidget);
|
||||||
dockWidget->hide();
|
dockWidget->hide();
|
||||||
// Prevent saveState storing the data of the wrong children.
|
|
||||||
dockWidget->setParent(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ICore::removeAdditionalContext(Context(Id::fromName(m_currentPerspectiveId)));
|
ICore::removeAdditionalContext(Context(Id::fromName(m_currentPerspectiveId)));
|
||||||
@@ -361,7 +361,7 @@ QDockWidget *DebuggerMainWindow::registerDockWidget(const QByteArray &dockId, QW
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(!widget->objectName().isEmpty(), return 0);
|
QTC_ASSERT(!widget->objectName().isEmpty(), return 0);
|
||||||
QDockWidget *dockWidget = addDockForWidget(widget);
|
QDockWidget *dockWidget = addDockForWidget(widget);
|
||||||
dockWidget->setParent(0);
|
dockWidget->setParent(this);
|
||||||
m_dockForDockId[dockId] = dockWidget;
|
m_dockForDockId[dockId] = dockWidget;
|
||||||
return dockWidget;
|
return dockWidget;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user