Skip to content

Central dock area pointer invalid after restoreState() Version:4.5 #824

@XHY-ChuJian

Description

@XHY-ChuJian

Description:

Hi, I found that after calling CDockManager::restoreState(), my pointer to the central dock area becomes invalid. Here’s a minimal example:

// Create central dock area
auto* dock = m_DockManager->createDockWidget("WelcomePage");
dock->setWidget(new QLabel("Welcome"));
m_CenterArea = m_DockManager->setCentralWidget(dock);

// Later, restore previous layout
m_DockManager->restoreState(savedState);

// After this, m_CenterArea is invalid
m_DockManager->addDockWidgetTabToArea(newDock, m_CenterArea); // may crash

// Workaround: reset central area pointer
m_CenterArea = m_DockManager->centralWidgetArea();
m_DockManager->addDockWidgetTabToArea(newDock, m_CenterArea); // works

Question:

Is it expected that restoreState() destroys and recreates the internal dock areas?
Is re-fetching the central area using centralWidgetArea() the intended way to recover it after restoring the layout?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions