Commit cd6b667e authored by Nikita Sirgienko's avatar Nikita Sirgienko

Fix errors with finishExpression

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