diff options
author | hjk <hjk@qt.io> | 2019-03-22 07:35:48 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2019-04-05 15:53:51 +0000 |
commit | 5273ef2a8aa3c8d268b107edc770b53e1aed7803 (patch) | |
tree | bfaa22f2f69e7a4a8bf5049c4d1f3588ffb74f31 /src/plugins/debugger/enginemanager.cpp | |
parent | 6ee855a2bc2678d477109f1370a8c73ea044cb90 (diff) | |
download | qt-creator-5273ef2a8aa3c8d268b107edc770b53e1aed7803.tar.gz |
Debugger: Re-organize dock widget persisting
Looks like the mainwindow cannot be convinced to handle multiple
sets of dockwidgets.
So switch back to a single set containing everything and keep
track of non-default visibility in the perspectives, and persist
these sets.
The following pass:
1.
Start Creator with new settings
Goto Debug Mode
Move Break dock widget to right, switch on Global log widget
Leave Creator
Start Creator
Goto Debug Mode
Check: Debugger Selected, Break on right, Global log visible
2.
Start Creator with new settings
Goto Debug Mode
Move Break dock widget to right, switch on Global log widget
Switch to QmlProfiler sub-perspective
Leave Creator
Start Creator
Goto Debug Mode
Check QmlProfiler selected
Switch to Debugger sub-perspective
Check: Debugger Selected, Break on right, Global log visible
3.
Start Creator with new settings
Use any C++ test project
Start debugging / stop at main() (F10)
Wait for stop
Switch to Edit mode
Switch back to Debug mode
Check: Only "running" debugger dock widget layout present
(not the normal + preset at the same time)
Quit Qt Creator while this debugger is running
Check: Shuts down without crash
4.
Use any C++ test project
Start debugging
Switch to Debugger Preset perspective
Start a second debugger
Kill either instance
Check: Application dies, Debugger Preset perspective gets displayed
Switch to perspective of second instance
Check: Perspective looks ok (docks visible as before)
Task-number: QTCREATORBUG-21083
Task-number: QTCREATORBUG-21669
Task-number: QTCREATORBUG-21668
Task-number: QTCREATORBUG-21813
Task-number: QTCREATORBUG-21851
Task-number: QTCREATORBUG-22110
Task-number: QTCREATORBUG-22169
Task-number: QTCREATORBUG-22189
Change-Id: Ic9eb41ff7699ac0f48a85e68376daa80b2b6847e
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Diffstat (limited to 'src/plugins/debugger/enginemanager.cpp')
-rw-r--r-- | src/plugins/debugger/enginemanager.cpp | 147 |
1 files changed, 83 insertions, 64 deletions
diff --git a/src/plugins/debugger/enginemanager.cpp b/src/plugins/debugger/enginemanager.cpp index 883668e498..ea4c67bb6e 100644 --- a/src/plugins/debugger/enginemanager.cpp +++ b/src/plugins/debugger/enginemanager.cpp @@ -155,16 +155,18 @@ public: } EngineItem *findEngineItem(DebuggerEngine *engine); - void activateEngine(DebuggerEngine *engine); void activateEngineItem(EngineItem *engineItem); void activateEngineByIndex(int index); void selectUiForCurrentEngine(); void updateEngineChooserVisibility(); + void updatePerspectives(); TreeModel<TypedTreeItem<EngineItem>, EngineItem> m_engineModel; - QPointer<EngineItem> m_currentItem; + QPointer<EngineItem> m_currentItem; // The primary information is DebuggerMainWindow::d->m_currentPerspective Core::Id m_previousMode; QPointer<QComboBox> m_engineChooser; + bool m_shuttingDown = false; + Context m_currentAdditionalContext; }; //////////////////////////////////////////////////////////////////////// @@ -192,6 +194,11 @@ QWidget *EngineManager::engineChooser() return d->m_engineChooser; } +void EngineManager::updatePerspectives() +{ + d->updatePerspectives(); +} + EngineManager::~EngineManager() { theEngineManager = nullptr; @@ -208,11 +215,6 @@ QAbstractItemModel *EngineManager::model() return &d->m_engineModel; } -void EngineManager::activateEngine(DebuggerEngine *engine) -{ - d->activateEngine(engine); -} - QVariant EngineItem::data(int column, int role) const { if (m_engine) { @@ -273,7 +275,7 @@ bool EngineItem::setData(int row, const QVariant &value, int role) if (role == BaseTreeView::ItemActivatedRole) { EngineItem *engineItem = d->findEngineItem(m_engine); - d->activateEngineItem(engineItem); + d->activateEngineByIndex(engineItem->indexInParent()); return true; } @@ -316,21 +318,27 @@ bool EngineItem::setData(int row, const QVariant &value, int role) void EngineManagerPrivate::activateEngineByIndex(int index) { - activateEngineItem(m_engineModel.rootItem()->childAt(index)); + // The actual activation is triggered indirectly via the perspective change. + Perspective *perspective = nullptr; + if (index == 0) { + perspective = Perspective::findPerspective(Debugger::Constants::PRESET_PERSPECTIVE_ID); + } else { + EngineItem *engineItem = m_engineModel.rootItem()->childAt(index); + QTC_ASSERT(engineItem, return); + QTC_ASSERT(engineItem->m_engine, return); + perspective = engineItem->m_engine->perspective(); + } + + QTC_ASSERT(perspective, return); + perspective->select(); } void EngineManagerPrivate::activateEngineItem(EngineItem *engineItem) { - Context previousContext; - if (m_currentItem) { - if (DebuggerEngine *engine = m_currentItem->m_engine) { - previousContext.add(engine->languageContext()); - previousContext.add(engine->debuggerContext()); - } else { - previousContext.add(Context(Constants::C_DEBUGGER_NOTRUNNING)); - } - } + if (m_currentItem == engineItem) + return; + QTC_ASSERT(engineItem, return); m_currentItem = engineItem; Context newContext; @@ -343,7 +351,13 @@ void EngineManagerPrivate::activateEngineItem(EngineItem *engineItem) } } - ICore::updateAdditionalContexts(previousContext, newContext); + ICore::updateAdditionalContexts(m_currentAdditionalContext, newContext); + m_currentAdditionalContext = newContext; + + // In case this was triggered externally by some Perspective::select() call. + const int idx = engineItem->indexInParent(); + m_engineChooser->setCurrentIndex(idx); + selectUiForCurrentEngine(); } @@ -352,12 +366,7 @@ void EngineManagerPrivate::selectUiForCurrentEngine() if (ModeManager::currentModeId() != Constants::MODE_DEBUG) return; - Perspective *perspective = nullptr; int row = 0; - - if (m_currentItem && m_currentItem->m_engine) - perspective = m_currentItem->m_engine->perspective(); - if (m_currentItem) row = m_engineModel.rootItem()->indexOf(m_currentItem); @@ -370,12 +379,6 @@ void EngineManagerPrivate::selectUiForCurrentEngine() QStyle::CT_ComboBox, &option, sz).width(); m_engineChooser->setFixedWidth(width); - if (!perspective) - perspective = Perspective::findPerspective(Debugger::Constants::PRESET_PERSPECTIVE_ID); - - QTC_ASSERT(perspective, return); - perspective->select(); - m_engineModel.rootItem()->forFirstLevelChildren([this](EngineItem *engineItem) { if (engineItem && engineItem->m_engine) engineItem->m_engine->updateUi(engineItem == m_currentItem); @@ -391,12 +394,6 @@ EngineItem *EngineManagerPrivate::findEngineItem(DebuggerEngine *engine) }); } -void EngineManagerPrivate::activateEngine(DebuggerEngine *engine) -{ - EngineItem *engineItem = findEngineItem(engine); - activateEngineItem(engineItem); -} - void EngineManagerPrivate::updateEngineChooserVisibility() { // Show it if there's more than one option (i.e. not the preset engine only) @@ -406,12 +403,48 @@ void EngineManagerPrivate::updateEngineChooserVisibility() } } -void EngineManager::registerEngine(DebuggerEngine *engine) +void EngineManagerPrivate::updatePerspectives() +{ + d->updateEngineChooserVisibility(); + + Perspective *current = DebuggerMainWindow::currentPerspective(); + if (!current) { + return; + } + + m_engineModel.rootItem()->forFirstLevelChildren([this, current](EngineItem *engineItem) { + if (engineItem == m_currentItem) + return; + + bool shouldBeActive = false; + if (engineItem->m_engine) { + // Normal engine. + shouldBeActive = engineItem->m_engine->perspective()->isCurrent(); + } else { + // Preset. + shouldBeActive = current->id() == Debugger::Constants::PRESET_PERSPECTIVE_ID; + } + + if (shouldBeActive && engineItem != m_currentItem) + activateEngineItem(engineItem); + }); +} + +QString EngineManager::registerEngine(DebuggerEngine *engine) { auto engineItem = new EngineItem; engineItem->m_engine = engine; d->m_engineModel.rootItem()->appendChild(engineItem); d->updateEngineChooserVisibility(); + return QString::number(d->m_engineModel.rootItem()->childCount()); +} + +void EngineManager::unregisterEngine(DebuggerEngine *engine) +{ + EngineItem *engineItem = d->findEngineItem(engine); + QTC_ASSERT(engineItem, return); + d->m_engineModel.destroyItem(engineItem); + d->updateEngineChooserVisibility(); } void EngineManager::activateDebugMode() @@ -434,33 +467,6 @@ void EngineManager::deactivateDebugMode() } } -bool EngineManager::isLastOf(const QString &type) -{ - int count = 0; - d->m_engineModel.rootItem()->forFirstLevelChildren([&](EngineItem *engineItem) { - if (engineItem && engineItem->m_engine) - count += (engineItem->m_engine->debuggerName() == type); - }); - return count == 1; -} - -void EngineManager::unregisterEngine(DebuggerEngine *engine) -{ - if (ModeManager::currentModeId() == Constants::MODE_DEBUG) { - if (Perspective *parent = Perspective::findPerspective(Constants::PRESET_PERSPECTIVE_ID)) - parent->select(); - } - - d->activateEngineItem(d->m_engineModel.rootItem()->childAt(0)); // Preset. - - // Could be that the run controls died before it was appended. - if (auto engineItem = d->findEngineItem(engine)) - d->m_engineModel.destroyItem(engineItem); - - d->updateEngineChooserVisibility(); - emit theEngineManager->currentEngineChanged(); -} - QList<QPointer<DebuggerEngine>> EngineManager::engines() { QList<QPointer<DebuggerEngine>> result; @@ -476,5 +482,18 @@ QPointer<DebuggerEngine> EngineManager::currentEngine() return d->m_currentItem ? d->m_currentItem->m_engine : nullptr; } +bool EngineManager::shutDown() +{ + d->m_shuttingDown = true; + bool anyEngineAborting = false; + for (DebuggerEngine *engine : EngineManager::engines()) { + if (engine && engine->state() != Debugger::DebuggerNotReady) { + engine->abortDebugger(); + anyEngineAborting = true; + } + } + return anyEngineAborting; +} + } // namespace Internal } // namespace Debugger |