forked from qt-creator/qt-creator
ProjectExplorer: Fix recent indeterministic state of stop button
The recent RunControl related changes have led to several regressions in the fragile handling of button states in the output pane. Take advantage of the new Starting phase to fix disabling of the run and enabling of the stop button at reasonable times. Change-Id: Iae191a840484dd08d61facf6b9f439bfafcbbcb0 Task-number: QTCREATORBUG-18508 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -403,7 +403,9 @@ void AppOutputPane::updateBehaviorSettings()
|
|||||||
void AppOutputPane::createNewOutputWindow(RunControl *rc)
|
void AppOutputPane::createNewOutputWindow(RunControl *rc)
|
||||||
{
|
{
|
||||||
connect(rc, &RunControl::aboutToStart,
|
connect(rc, &RunControl::aboutToStart,
|
||||||
this, &AppOutputPane::slotRunControlStarted);
|
this, &AppOutputPane::slotRunControlChanged);
|
||||||
|
connect(rc, &RunControl::started,
|
||||||
|
this, &AppOutputPane::slotRunControlChanged);
|
||||||
connect(rc, &RunControl::finished,
|
connect(rc, &RunControl::finished,
|
||||||
this, &AppOutputPane::slotRunControlFinished);
|
this, &AppOutputPane::slotRunControlFinished);
|
||||||
connect(rc, &RunControl::applicationProcessHandleChanged,
|
connect(rc, &RunControl::applicationProcessHandleChanged,
|
||||||
@@ -620,9 +622,7 @@ void AppOutputPane::projectRemoved()
|
|||||||
|
|
||||||
void AppOutputPane::enableDefaultButtons()
|
void AppOutputPane::enableDefaultButtons()
|
||||||
{
|
{
|
||||||
const RunControl *rc = currentRunControl();
|
enableButtons(currentRunControl());
|
||||||
const bool isRunning = rc && rc->isRunning();
|
|
||||||
enableButtons(rc, isRunning);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppOutputPane::zoomIn()
|
void AppOutputPane::zoomIn()
|
||||||
@@ -643,10 +643,11 @@ void AppOutputPane::zoomOut()
|
|||||||
m_zoom = m_runControlTabs.first().window->fontZoom();
|
m_zoom = m_runControlTabs.first().window->fontZoom();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppOutputPane::enableButtons(const RunControl *rc, bool isRunning)
|
void AppOutputPane::enableButtons(const RunControl *rc)
|
||||||
{
|
{
|
||||||
if (rc) {
|
if (rc) {
|
||||||
m_reRunButton->setEnabled(!isRunning && rc->supportsReRunning());
|
const bool isRunning = rc->isRunning();
|
||||||
|
m_reRunButton->setEnabled(rc->isStopped() && rc->supportsReRunning());
|
||||||
m_reRunButton->setIcon(rc->icon().icon());
|
m_reRunButton->setIcon(rc->icon().icon());
|
||||||
m_stopAction->setEnabled(isRunning);
|
m_stopAction->setEnabled(isRunning);
|
||||||
if (isRunning && debuggerPlugin() && rc->applicationProcessHandle().isValid()) {
|
if (isRunning && debuggerPlugin() && rc->applicationProcessHandle().isValid()) {
|
||||||
@@ -681,8 +682,7 @@ void AppOutputPane::tabChanged(int i)
|
|||||||
{
|
{
|
||||||
const int index = indexOf(m_tabWidget->widget(i));
|
const int index = indexOf(m_tabWidget->widget(i));
|
||||||
if (i != -1 && index != -1) {
|
if (i != -1 && index != -1) {
|
||||||
const RunControl *rc = m_runControlTabs.at(index).runControl;
|
enableButtons(m_runControlTabs.at(index).runControl);
|
||||||
enableButtons(rc, rc->isRunning());
|
|
||||||
} else {
|
} else {
|
||||||
enableDefaultButtons();
|
enableDefaultButtons();
|
||||||
}
|
}
|
||||||
@@ -705,11 +705,11 @@ void AppOutputPane::contextMenuRequested(const QPoint &pos, int index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppOutputPane::slotRunControlStarted()
|
void AppOutputPane::slotRunControlChanged()
|
||||||
{
|
{
|
||||||
RunControl *current = currentRunControl();
|
RunControl *current = currentRunControl();
|
||||||
if (current && current == sender())
|
if (current && current == sender())
|
||||||
enableButtons(current, true); // RunControl::isRunning() cannot be trusted in signal handler.
|
enableButtons(current); // RunControl::isRunning() cannot be trusted in signal handler.
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppOutputPane::slotRunControlFinished()
|
void AppOutputPane::slotRunControlFinished()
|
||||||
@@ -736,7 +736,7 @@ void AppOutputPane::slotRunControlFinished2(RunControl *sender)
|
|||||||
<< " current " << current << m_runControlTabs.size();
|
<< " current " << current << m_runControlTabs.size();
|
||||||
|
|
||||||
if (current && current == sender)
|
if (current && current == sender)
|
||||||
enableButtons(current, false); // RunControl::isRunning() cannot be trusted in signal handler.
|
enableButtons(current);
|
||||||
|
|
||||||
ProjectExplorerPlugin::instance()->updateRunActions();
|
ProjectExplorerPlugin::instance()->updateRunActions();
|
||||||
|
|
||||||
|
@@ -107,7 +107,7 @@ private:
|
|||||||
void attachToRunControl();
|
void attachToRunControl();
|
||||||
void tabChanged(int);
|
void tabChanged(int);
|
||||||
void contextMenuRequested(const QPoint &pos, int index);
|
void contextMenuRequested(const QPoint &pos, int index);
|
||||||
void slotRunControlStarted();
|
void slotRunControlChanged();
|
||||||
void slotRunControlFinished();
|
void slotRunControlFinished();
|
||||||
void slotRunControlFinished2(ProjectExplorer::RunControl *sender);
|
void slotRunControlFinished2(ProjectExplorer::RunControl *sender);
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ private:
|
|||||||
void zoomIn();
|
void zoomIn();
|
||||||
void zoomOut();
|
void zoomOut();
|
||||||
|
|
||||||
void enableButtons(const RunControl *rc, bool isRunning);
|
void enableButtons(const RunControl *rc);
|
||||||
|
|
||||||
class RunControlTab {
|
class RunControlTab {
|
||||||
public:
|
public:
|
||||||
|
@@ -1117,6 +1117,11 @@ bool RunControl::isStopping() const
|
|||||||
return d->state == RunControlState::Stopping;
|
return d->state == RunControlState::Stopping;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RunControl::isStopped() const
|
||||||
|
{
|
||||||
|
return d->state == RunControlState::Stopped;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Prompts to terminate the application with the \gui {Do not ask again}
|
Prompts to terminate the application with the \gui {Do not ask again}
|
||||||
checkbox.
|
checkbox.
|
||||||
|
@@ -446,6 +446,7 @@ public:
|
|||||||
bool isRunning() const;
|
bool isRunning() const;
|
||||||
bool isStarting() const;
|
bool isStarting() const;
|
||||||
bool isStopping() const;
|
bool isStopping() const;
|
||||||
|
bool isStopped() const;
|
||||||
|
|
||||||
void setIcon(const Utils::Icon &icon);
|
void setIcon(const Utils::Icon &icon);
|
||||||
Utils::Icon icon() const;
|
Utils::Icon icon() const;
|
||||||
|
Reference in New Issue
Block a user