Delete QObject::setParent() in the controller

To find places where we're setting parent on the controller instead
of in the view. Fix such case where the dock widget view
wasn't being parented to the frame view.
This commit is contained in:
Sergio Martins
2022-05-27 13:25:06 +01:00
parent 5fdbc12524
commit fb8639969c
4 changed files with 7 additions and 4 deletions

View File

@@ -81,6 +81,7 @@ public:
bool inDtor() const;
private:
void setParent(QObject *) = delete;
View *m_view = nullptr;
bool m_inDtor = false;
const Type m_type;

View File

@@ -112,7 +112,7 @@ void DockWidget::addDockWidgetAsTab(DockWidget *other, InitialOption option)
}
}
other->setParent(nullptr);
other->view()->setParent(nullptr);
frame->addWidget(other, option);
}
@@ -384,6 +384,7 @@ QStringList DockWidget::affinities() const
void DockWidget::show()
{
// TODOv2: show wont be called. move to view instead.
if (view()->isRootView() && (d->m_lastPosition->wasFloating() || !d->m_lastPosition->isValid())) {
// Create the FloatingWindow already, instead of waiting for the show event.
// This reduces flickering on some platforms
@@ -734,7 +735,7 @@ void DockWidget::Private::close()
// Do some cleaning. Widget is hidden, but we must hide the tab containing it.
if (Controllers::Frame *frame = this->frame()) {
q->setParent(nullptr);
q->QObject::setParent(nullptr);
q->view()->setParent(nullptr);
frame->removeWidget(q);

View File

@@ -586,7 +586,7 @@ void MainWindow::clearSideBarOverlay(bool deleteFrame)
frame->unoverlay();
if (deleteFrame) {
d->m_overlayedDockWidget->setParent(nullptr);
d->m_overlayedDockWidget->QObject::setParent(nullptr);
d->m_overlayedDockWidget->view()->setParent(nullptr);
Q_EMIT d->m_overlayedDockWidget->isOverlayedChanged(false);
d->m_overlayedDockWidget = nullptr;

View File

@@ -142,7 +142,8 @@ void Frame_qtquick::insertDockWidget_impl(Controllers::DockWidget *dw, int index
{
QPointer<Controllers::Frame> oldFrame = dw->d->frame();
if (stackView()->insertDockWidget(index, dw, {}, {})) {
dw->setParent(m_stackLayout);
asView_qtquick(dw->view())->setParent(m_stackLayout);
QMetaObject::Connection conn = connect(dw, &Controllers::DockWidget::parentChanged, this, [dw, this] {
if (dw->parent() != m_stackLayout)