ApplicationOutputPane: Handle runControl being nullptr

The runControl associated with a tab might become nullptr. That was
already handled in some places. Do so consistently now.

Change-Id: I899cc467a213f2a991967fa98a5819a98412d387
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Tobias Hunger
2017-11-14 13:11:06 +01:00
parent 77bea93a6e
commit 69e9f81bd8

View File

@@ -321,7 +321,7 @@ void AppOutputPane::updateCloseActions()
bool AppOutputPane::aboutToClose() const
{
return Utils::allOf(m_runControlTabs, [](const RunControlTab &rt) {
return !rt.runControl->isRunning() || rt.runControl->promptToStop();
return !rt.runControl || !rt.runControl->isRunning() || rt.runControl->promptToStop();
});
}
@@ -507,9 +507,9 @@ void AppOutputPane::setBehaviorOnOutput(RunControl *rc, AppOutputPane::BehaviorO
void AppOutputPane::reRunRunControl()
{
const int index = currentIndex();
QTC_ASSERT(index != -1 && !m_runControlTabs.at(index).runControl->isRunning(), return);
RunControlTab &tab = m_runControlTabs[index];
const RunControlTab &tab = m_runControlTabs.at(index);
QTC_ASSERT(tab.runControl, return);
QTC_ASSERT(index != -1 && !tab.runControl->isRunning(), return);
handleOldOutput(tab.window);
tab.window->scrollToBottom();
@@ -521,7 +521,7 @@ void AppOutputPane::attachToRunControl()
const int index = currentIndex();
QTC_ASSERT(index != -1, return);
RunControl *rc = m_runControlTabs.at(index).runControl;
QTC_ASSERT(rc->isRunning(), return);
QTC_ASSERT(rc && rc->isRunning(), return);
ExtensionSystem::Invoker<void>(debuggerPlugin(), "attachExternalApplication", rc);
}
@@ -551,9 +551,10 @@ void AppOutputPane::closeTabs(CloseTabMode mode)
QList<RunControl *> AppOutputPane::allRunControls() const
{
return Utils::transform<QList>(m_runControlTabs,[](const RunControlTab &tab) {
const QList<RunControl *> list = Utils::transform<QList>(m_runControlTabs,[](const RunControlTab &tab) {
return tab.runControl.data();
});
return Utils::filtered(list, [](RunControl *rc) { return rc; });
}
void AppOutputPane::closeTab(int tabIndex, CloseTabMode closeTabMode)
@@ -568,7 +569,7 @@ void AppOutputPane::closeTab(int tabIndex, CloseTabMode closeTabMode)
// Prompt user to stop
if (closeTabMode == CloseTabWithPrompt) {
QWidget *tabWidget = m_tabWidget->widget(tabIndex);
if (runControl->isRunning() && !runControl->promptToStop())
if (runControl && runControl->isRunning() && !runControl->promptToStop())
return;
// The event loop has run, thus the ordering might have changed, a tab might
// have been closed, so do some strange things...