| 172 | } |
| 173 | |
| 174 | void DockLayout::thaw() |
| 175 | { |
| 176 | pxAssert(!m_is_active); |
| 177 | m_is_active = true; |
| 178 | |
| 179 | if (!g_debugger_window) |
| 180 | return; |
| 181 | |
| 182 | // Restore the state of the toolbars. |
| 183 | if (m_toolbars.isEmpty()) |
| 184 | { |
| 185 | const DockTables::DefaultDockLayout* base_layout = DockTables::defaultLayout(m_base_layout); |
| 186 | if (base_layout) |
| 187 | { |
| 188 | for (QToolBar* toolbar : g_debugger_window->findChildren<QToolBar*>()) |
| 189 | if (base_layout->toolbars.contains(toolbar->objectName().toStdString())) |
| 190 | toolbar->show(); |
| 191 | } |
| 192 | } |
| 193 | else |
| 194 | { |
| 195 | g_debugger_window->restoreState(m_toolbars); |
| 196 | } |
| 197 | |
| 198 | if (m_geometry.isEmpty()) |
| 199 | { |
| 200 | // This is a newly created layout with no geometry information. |
| 201 | setupDefaultLayout(); |
| 202 | } |
| 203 | else |
| 204 | { |
| 205 | // Create all the dock widgets. |
| 206 | KDDockWidgets::LayoutSaver saver(KDDockWidgets::RestoreOption_RelativeToMainWindow); |
| 207 | if (!saver.restoreLayout(m_geometry)) |
| 208 | { |
| 209 | // We've failed to restore the geometry, so just tear down whatever |
| 210 | // dock widgets may exist and then setup the default layout. |
| 211 | for (KDDockWidgets::Core::DockWidget* dock : KDDockWidgets::DockRegistry::self()->dockwidgets()) |
| 212 | { |
| 213 | // Make sure the dock widget releases ownership of its content. |
| 214 | auto view = static_cast<KDDockWidgets::QtWidgets::DockWidget*>(dock->view()); |
| 215 | view->setWidget(new QWidget()); |
| 216 | |
| 217 | delete dock; |
| 218 | } |
| 219 | |
| 220 | setupDefaultLayout(); |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | // Check that all the dock widgets have been restored correctly. |
| 225 | std::vector<QString> orphaned_debugger_views; |
| 226 | for (auto& [unique_name, widget] : m_widgets) |
| 227 | { |
| 228 | auto [controller, view] = DockUtils::dockWidgetFromName(unique_name); |
| 229 | if (!controller || !view) |
| 230 | { |
| 231 | Console.Error("Debugger: Failed to restore dock widget '%s'.", unique_name.toStdString().c_str()); |