forked from qt-creator/qt-creator
RunControl: Make sure to reset the outputformater
Make sure to reset the outputformater in the RunControl's Application Output Tab when the runControl finishes. Change-Id: I7014727580f56f3769f1308da53a1e37231fba22 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -196,7 +196,8 @@ OutputFormatter *OutputWindow::formatter() const
|
||||
void OutputWindow::setFormatter(OutputFormatter *formatter)
|
||||
{
|
||||
d->formatter = formatter;
|
||||
d->formatter->setPlainTextEdit(this);
|
||||
if (d->formatter)
|
||||
d->formatter->setPlainTextEdit(this);
|
||||
}
|
||||
|
||||
void OutputWindow::showEvent(QShowEvent *e)
|
||||
@@ -286,9 +287,8 @@ void OutputWindow::appendMessage(const QString &output, OutputFormat format)
|
||||
const bool atBottom = isScrollbarAtBottom() || m_scrollTimer.isActive();
|
||||
|
||||
if (format == ErrorMessageFormat || format == NormalMessageFormat) {
|
||||
|
||||
d->formatter->appendMessage(doNewlineEnforcement(out), format);
|
||||
|
||||
if (d->formatter)
|
||||
d->formatter->appendMessage(doNewlineEnforcement(out), format);
|
||||
} else {
|
||||
|
||||
bool sameLine = format == StdOutFormatSameLine
|
||||
@@ -304,7 +304,7 @@ void OutputWindow::appendMessage(const QString &output, OutputFormat format)
|
||||
if (!enforceNewline) {
|
||||
newline = out.indexOf(QLatin1Char('\n'));
|
||||
moveCursor(QTextCursor::End);
|
||||
if (newline != -1)
|
||||
if (newline != -1 && d->formatter)
|
||||
d->formatter->appendMessage(out.left(newline), format);// doesn't enforce new paragraph like appendPlainText
|
||||
}
|
||||
|
||||
@@ -316,10 +316,12 @@ void OutputWindow::appendMessage(const QString &output, OutputFormat format)
|
||||
d->enforceNewline = true;
|
||||
s.chop(1);
|
||||
}
|
||||
d->formatter->appendMessage(QLatin1Char('\n') + s, format);
|
||||
if (d->formatter)
|
||||
d->formatter->appendMessage(QLatin1Char('\n') + s, format);
|
||||
}
|
||||
} else {
|
||||
d->formatter->appendMessage(doNewlineEnforcement(out), format);
|
||||
if (d->formatter)
|
||||
d->formatter->appendMessage(doNewlineEnforcement(out), format);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -259,8 +259,10 @@ AppOutputPane::~AppOutputPane()
|
||||
if (debug)
|
||||
qDebug() << "OutputPane::~OutputPane: Entries left" << m_runControlTabs.size();
|
||||
|
||||
foreach (const RunControlTab &rt, m_runControlTabs)
|
||||
foreach (const RunControlTab &rt, m_runControlTabs) {
|
||||
rt.window->setFormatter(nullptr);
|
||||
delete rt.runControl;
|
||||
}
|
||||
delete m_mainWidget;
|
||||
}
|
||||
|
||||
@@ -282,7 +284,7 @@ RunControl *AppOutputPane::currentRunControl() const
|
||||
const int index = currentIndex();
|
||||
if (index != -1)
|
||||
return m_runControlTabs.at(index).runControl;
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int AppOutputPane::indexOf(const RunControl *rc) const
|
||||
@@ -404,8 +406,6 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc)
|
||||
connect(rc, &RunControl::appendMessageRequested,
|
||||
this, &AppOutputPane::appendMessage);
|
||||
|
||||
Utils::OutputFormatter *formatter = rc->outputFormatter();
|
||||
|
||||
// First look if we can reuse a tab
|
||||
const int tabIndex = Utils::indexOf(m_runControlTabs, [rc](const RunControlTab &tab) {
|
||||
return rc->canReUseOutputPane(tab.runControl);
|
||||
@@ -414,22 +414,22 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc)
|
||||
RunControlTab &tab = m_runControlTabs[tabIndex];
|
||||
// Reuse this tab
|
||||
delete tab.runControl;
|
||||
tab.runControl = rc;
|
||||
handleOldOutput(tab.window);
|
||||
tab.runControl = rc;
|
||||
tab.window->setFormatter(nullptr);
|
||||
tab.window->scrollToBottom();
|
||||
tab.window->setFormatter(formatter);
|
||||
if (debug)
|
||||
qDebug() << "OutputPane::createNewOutputWindow: Reusing tab" << tabIndex << " for " << rc;
|
||||
return;
|
||||
}
|
||||
// Create new
|
||||
static uint counter = 0;
|
||||
static int counter = 0;
|
||||
Core::Id contextId = Core::Id(Constants::C_APP_OUTPUT).withSuffix(counter++);
|
||||
Core::Context context(contextId);
|
||||
Core::OutputWindow *ow = new Core::OutputWindow(context, m_tabWidget);
|
||||
ow->setWindowTitle(tr("Application Output Window"));
|
||||
ow->setWindowIcon(Icons::WINDOW.icon());
|
||||
ow->setFormatter(formatter);
|
||||
ow->setFormatter(nullptr);
|
||||
ow->setWordWrapEnabled(ProjectExplorerPlugin::projectExplorerSettings().wrapAppOutput);
|
||||
ow->setMaxLineCount(ProjectExplorerPlugin::projectExplorerSettings().maxAppOutputLines);
|
||||
ow->setWheelZoomEnabled(TextEditor::TextEditorSettings::behaviorSettings().m_scrollWheelZooming);
|
||||
@@ -586,6 +586,7 @@ bool AppOutputPane::closeTab(int tabIndex, CloseTabMode closeTabMode)
|
||||
}
|
||||
|
||||
m_tabWidget->removeTab(tabIndex);
|
||||
m_runControlTabs[index].window->setFormatter(nullptr);
|
||||
delete m_runControlTabs[index].runControl;
|
||||
delete m_runControlTabs[index].window;
|
||||
m_runControlTabs.removeAt(index);
|
||||
@@ -701,6 +702,10 @@ void AppOutputPane::contextMenuRequested(const QPoint &pos, int index)
|
||||
void AppOutputPane::slotRunControlStarted()
|
||||
{
|
||||
RunControl *current = currentRunControl();
|
||||
const int rcIndex = indexOf(current);
|
||||
if (rcIndex >= 0 && m_runControlTabs.at(rcIndex).window)
|
||||
m_runControlTabs.at(rcIndex).window->setFormatter(current->outputFormatter());
|
||||
|
||||
if (current && current == sender())
|
||||
enableButtons(current, true); // RunControl::isRunning() cannot be trusted in signal handler.
|
||||
emit runControlStarted(current);
|
||||
@@ -710,7 +715,8 @@ void AppOutputPane::slotRunControlFinished()
|
||||
{
|
||||
RunControl *rc = qobject_cast<RunControl *>(sender());
|
||||
QTimer::singleShot(0, this, [this, rc]() { slotRunControlFinished2(rc); });
|
||||
rc->outputFormatter()->flush();
|
||||
if (rc->outputFormatter())
|
||||
rc->outputFormatter()->flush();
|
||||
}
|
||||
|
||||
void AppOutputPane::slotRunControlFinished2(RunControl *sender)
|
||||
@@ -731,6 +737,8 @@ void AppOutputPane::slotRunControlFinished2(RunControl *sender)
|
||||
if (current && current == sender)
|
||||
enableButtons(current, false); // RunControl::isRunning() cannot be trusted in signal handler.
|
||||
|
||||
m_runControlTabs.at(senderIndex).window->setFormatter(nullptr); // Reset formater for this RC
|
||||
|
||||
// Check for asynchronous close. Close the tab.
|
||||
if (m_runControlTabs.at(senderIndex).asyncClosing)
|
||||
closeTab(tabWidgetIndexOf(senderIndex), CloseTabNoPrompt);
|
||||
|
@@ -511,10 +511,6 @@ public:
|
||||
device = DeviceKitInformation::device(runConfiguration->target()->kit());
|
||||
project = runConfiguration->target()->project();
|
||||
}
|
||||
|
||||
// We need to ensure that there's always a OutputFormatter
|
||||
if (!outputFormatter)
|
||||
outputFormatter = new Utils::OutputFormatter();
|
||||
}
|
||||
|
||||
~RunControlPrivate()
|
||||
|
Reference in New Issue
Block a user