Commit cd6b667e authored by Nikita Sirgienko's avatar Nikita Sirgienko

Fix errors with finishExpression

parent 1fb13e35
......@@ -34,10 +34,11 @@
#include <signal.h>
#endif
RSession::RSession(Cantor::Backend* backend) : Session(backend, new RVariableModel(this)),
RSession::RSession(Cantor::Backend* backend) : Session(backend),
m_process(nullptr),
m_rServer(nullptr)
{
setVariableModel(new RVariableModel(this));
}
RSession::~RSession()
......@@ -148,7 +149,6 @@ void RSession::serverChangedStatus(int status)
RExpression* expr = static_cast<RExpression*>(expressionQueue().first());
qDebug()<<"done running "<<expr<<" "<<expr->command();
}
finishFirstExpression();
}
else
......
......@@ -47,10 +47,11 @@ const QRegExp MaximaSession::MaximaOutputPrompt=QRegExp(QLatin1String("(\\(\\s*%
const QRegExp MaximaSession::MaximaInputPrompt = QRegExp(QLatin1String("(\\(\\s*%\\s*i\\s*[0-9\\s]*\\))"));
MaximaSession::MaximaSession( Cantor::Backend* backend ) : Session(backend, new MaximaVariableModel(this)),
MaximaSession::MaximaSession( Cantor::Backend* backend ) : Session(backend),
m_process(nullptr),
m_justRestarted(false)
{
setVariableModel(new MaximaVariableModel(this));
}
void MaximaSession::login()
......
......@@ -44,7 +44,7 @@
const QRegExp OctaveSession::PROMPT_UNCHANGEABLE_COMMAND = QRegExp(QLatin1String("(,|;)+"));
OctaveSession::OctaveSession ( Cantor::Backend* backend ) : Session ( backend, new OctaveVariableModel(this) ),
OctaveSession::OctaveSession ( Cantor::Backend* backend ) : Session ( backend),
m_process(nullptr),
m_prompt(QLatin1String("CANTOR_OCTAVE_BACKEND_PROMPT:([0-9]+)> ")),
m_subprompt(QLatin1String("CANTOR_OCTAVE_BACKEND_SUBPROMPT:([0-9]+)> ")),
......@@ -52,6 +52,7 @@ m_previousPromptNumber(1),
m_watch(nullptr),
m_syntaxError(false)
{
setVariableModel(new OctaveVariableModel(this));
qDebug() << octaveScriptInstallDir;
}
......@@ -181,7 +182,8 @@ void OctaveSession::logout()
m_output.clear();
m_previousPromptNumber = 1;
static_cast<OctaveVariableModel*>(variableModel())->clearVariables();
OctaveVariableModel* model = static_cast<OctaveVariableModel*>(variableModel());
model->clearVariables();
changeStatus(Status::Disable);
......
......@@ -85,7 +85,9 @@ void Session::runFirstExpression()
void Session::finishFirstExpression()
{
if (!d->expressionQueue.isEmpty())
d->needUpdate |= !d->expressionQueue.takeFirst()->isInternal();
if (d->expressionQueue.isEmpty())
if (d->variableModel && d->needUpdate)
{
......@@ -175,6 +177,11 @@ void Session::forceVariableUpdate()
}
}
void Cantor::Session::setVariableModel(Cantor::DefaultVariableModel* model)
{
d->variableModel = model;
}
int Session::nextExpressionId()
{
return d->expressionCount++;
......
......@@ -229,6 +229,11 @@ class CANTOR_EXPORT Session : public QObject
*/
virtual void forceVariableUpdate();
/**
* Setting variable model, usefull, if model constructor requires functional session
*/
void setVariableModel(DefaultVariableModel* model);
Q_SIGNALS:
void statusChanged(Cantor::Session::Status newStatus);
void loginStarted();
......
Markdown is supported
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