Add AssertionException, specialize pprint
diff --git a/ide/CellModel.cpp b/ide/CellModel.cpp
index 8271c87..0aa29bb 100644
--- a/ide/CellModel.cpp
+++ b/ide/CellModel.cpp
@@ -147,6 +147,11 @@
addCell(Cell(code, result));
}
+void CellModel::insertCellBefore(int index)
+{
+ insertRow(index);
+}
+
void CellModel::announceCellChange(Cell *cell, int role)
{
// TODO: Optimize
diff --git a/ide/CellModel.h b/ide/CellModel.h
index 1f56056..428422a 100644
--- a/ide/CellModel.h
+++ b/ide/CellModel.h
@@ -44,6 +44,8 @@
Q_INVOKABLE void addCell(const Cell &cell);
Q_INVOKABLE void addCell(QString code, QString result);
+ Q_INVOKABLE void insertCellBefore(int index);
+
private:
Notebook *_notebook;
void announceCellChange(Cell *cell, int role);
diff --git a/ide/NbRuntime.cpp b/ide/NbRuntime.cpp
index 8454597..35df413 100644
--- a/ide/NbRuntime.cpp
+++ b/ide/NbRuntime.cpp
@@ -2,10 +2,12 @@
#include "NbRuntime.h"
#include "../Parser.h"
+#include "../StdLib.h"
NbRuntime::NbRuntime(QObject *parent)
: QThread(parent)
{
+ StdLib().load(_eval);
}
void NbRuntime::queueCell(Cell *cell)
@@ -118,5 +120,10 @@
_running = nullptr;
emit cellFinishedRunning(cell, RuntimeResult(ex));
}
+ catch (AssertionException &ex)
+ {
+ _running = nullptr;
+ emit cellFinishedRunning(cell, RuntimeResult(ex));
+ }
}
}
diff --git a/ide/Notebook.cpp b/ide/Notebook.cpp
index 82bee7e..953e98b 100644
--- a/ide/Notebook.cpp
+++ b/ide/Notebook.cpp
@@ -2,6 +2,8 @@
#include "CellModel.h"
#include "../PPrint.h"
+// TODO: avoid potential race condition if Cell is deleted, pass by value with same UUID instead
+
Notebook::Notebook(QObject *parent)
: QObject(parent)
, _cellModel(new CellModel(this))
diff --git a/ide/qml/main.qml b/ide/qml/main.qml
index bf99a8d..ef6134a 100644
--- a/ide/qml/main.qml
+++ b/ide/qml/main.qml
@@ -76,7 +76,7 @@
}
InsertRow {
- onInsertClicked: notebook.cellModel.insertRows(notebook.cellModel.index(0, 0), 1);
+ onInsertClicked: notebook.cellModel.insertCellBefore(0)
}
}
@@ -86,7 +86,6 @@
required property var model
required property var index
required property var uuid
- required property int status
width: codeEditor.width - 5
@@ -98,7 +97,7 @@
onInsertBelowClicked: {
console.info(index);
- notebook.cellModel.insertRows(notebook.cellModel.index(index + 1, 0), 1);
+ notebook.cellModel.insertCellBefore(index + 1);
}
onRunClicked: {