Commit d5685223 authored by Alexander Semke's avatar Alexander Semke
Browse files

No need to update the variable model if a help request was processed since it...

No need to update the variable model if a help request was processed since it doesn't create any new variables of functions.
parent 979d60f3
Pipeline #152325 passed with stage
in 6 minutes and 6 seconds
......@@ -38,7 +38,6 @@ MaximaExpression::~MaximaExpression() {
void MaximaExpression::evaluate()
{
m_isHelpRequest = false;
m_gotErrorContent = false;
if(m_tempFile)
......@@ -66,7 +65,7 @@ void MaximaExpression::evaluate()
|| cmd.startsWith(QLatin1String("describe("))
|| cmd.startsWith(QLatin1String("example("))
|| cmd.startsWith(QLatin1String(":lisp(cl-info::info-exact")))
m_isHelpRequest=true;
setIsHelpRequest(true);
if (MaximaSettings::self()->integratePlots()
&& !cmd.contains(QLatin1String("ps_file"))
......@@ -221,7 +220,7 @@ void MaximaExpression::parseOutput(const QString& out)
int resultStart = out.indexOf(QLatin1String("<cantor-result>"));
if (resultStart != -1) {
errorContent += out.mid(0, resultStart);
if (!errorContent.isEmpty() && !(m_isHelpRequest || m_isHelpRequestAdditional))
if (!errorContent.isEmpty() && !(isHelpRequest() || m_isHelpRequestAdditional))
{
//there is a result but also the error buffer is not empty. This is the case when
//warnings are generated, for example, the output of rat(0.75*10) is:
......@@ -266,7 +265,7 @@ void MaximaExpression::parseOutput(const QString& out)
qDebug() << "error content: " << errorContent;
if (out.contains(QLatin1String("cantor-value-separator"))
|| (out.contains(QLatin1String("<cantor-result>")) && !(m_isHelpRequest || m_isHelpRequestAdditional)) )
|| (out.contains(QLatin1String("<cantor-result>")) && !(isHelpRequest() || m_isHelpRequestAdditional)) )
{
//we don't interpret the error output as an error in the following cases:
//1. when fetching variables, in addition to the actual result with variable names and values,
......@@ -297,7 +296,7 @@ void MaximaExpression::parseOutput(const QString& out)
addResult(result);
setStatus(Cantor::Expression::Done);
}
else if(m_isHelpRequest || m_isHelpRequestAdditional) //help messages are also part of the error output
else if(isHelpRequest() || m_isHelpRequestAdditional) //help messages are also part of the error output
{
//we've got help result, but maybe additional input is required -> check this
const int index = prompt.trimmed().indexOf(MaximaSession::MaximaInputPrompt);
......@@ -321,9 +320,14 @@ void MaximaExpression::parseOutput(const QString& out)
}
else
{
errorContent = errorContent.replace(QLatin1String("\n\n"), QLatin1String("\n"));
setErrorMessage(errorContent);
setStatus(Cantor::Expression::Error);
if (isInternal())
setStatus(Cantor::Expression::Done); //for internal commands no need to handle the error output
else
{
errorContent = errorContent.replace(QLatin1String("\n\n"), QLatin1String("\n"));
setErrorMessage(errorContent);
setStatus(Cantor::Expression::Error);
}
}
}
}
......
......@@ -27,21 +27,19 @@ using namespace Cantor;
class Cantor::ExpressionPrivate
{
public:
ExpressionPrivate() : id(-1), status(Expression::Done), session(nullptr),
finishingBehavior(Expression::DoNotDelete), internal(false), fileWatcher(nullptr)
{
}
ExpressionPrivate() : id(-1) {}
int id;
int id{-1};
QString command;
QString error;
QList<QString> information;
QVector<Result*> results;
Expression::Status status;
Session* session;
Expression::FinishingBehavior finishingBehavior;
bool internal;
QFileSystemWatcher* fileWatcher;
Expression::Status status{Expression::Done};
Session* session{nullptr};
Expression::FinishingBehavior finishingBehavior{Expression::DoNotDelete};
bool internal{false};
bool helpRequest{false};
QFileSystemWatcher* fileWatcher{nullptr};
};
static const QString tex=QLatin1String("\\documentclass[12pt,fleqn]{article} \n "\
......@@ -292,7 +290,17 @@ Expression::FinishingBehavior Expression::finishingBehavior()
return d->finishingBehavior;
}
bool Expression::isInternal()
bool Expression::isInternal() const
{
return d->internal;
}
void Expression::setIsHelpRequest(bool value)
{
d->helpRequest = value;
}
bool Expression::isHelpRequest() const
{
return d->helpRequest;
}
......@@ -60,7 +60,7 @@ class CANTOR_EXPORT Expression : public QObject
* @param session the session, this Expression belongs to
* @param internal \c true if this expression is internal expression
*/
explicit Expression( Session* session, bool internal = false);
explicit Expression(Session*, bool internal = false);
/**
* destructor
*/
......@@ -201,7 +201,15 @@ class CANTOR_EXPORT Expression : public QObject
* returns whether or not this expression is internal, or
* comes from the user
*/
bool isInternal();
bool isInternal() const;
/**
* Sets whether the expression is a help request (available for Maxima and R) where
* additional information/help can be requested and shown.
* Used internally to controll whether the update of the variable model needs to be done.
*/
void setIsHelpRequest(bool);
bool isHelpRequest() const;
Q_SIGNALS:
/**
......
......@@ -156,7 +156,10 @@ void Session::runFirstExpression()
void Session::finishFirstExpression(bool setDoneAfterUpdate)
{
if (!d->expressionQueue.isEmpty())
d->needUpdate |= !d->expressionQueue.takeFirst()->isInternal();
{
auto first = d->expressionQueue.takeFirst();
d->needUpdate |= !first->isInternal() && !first->isHelpRequest();
}
if (d->expressionQueue.isEmpty())
if (d->variableModel && d->needUpdate)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment