mirror of
https://gitlab.com/eql/lqml.git
synced 2025-12-29 13:23:11 -08:00
add simple restart for errors during Qt event processing
This commit is contained in:
parent
cb968f2d92
commit
50ec472e30
5 changed files with 37 additions and 7 deletions
|
|
@ -74,11 +74,22 @@ static cl_object safe_eval(const char* lisp_code) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
void LQML::eval(const QString& lisp_code) {
|
||||
cl_object ret = safe_eval(lisp_code.toLatin1().constData());
|
||||
if (ecl_t_of(ret) == t_fixnum && (fix(ret) == EVAL_ERROR_VALUE)) {
|
||||
qDebug() << "Error evaluating " << lisp_code;
|
||||
exit(-1);
|
||||
static void safe_eval_debug(const char* lisp_code) {
|
||||
CL_CATCH_ALL_BEGIN(ecl_process_env()) {
|
||||
si_safe_eval(2, ecl_read_from_cstring((char*)lisp_code), ECL_NIL);
|
||||
}
|
||||
CL_CATCH_ALL_END;
|
||||
}
|
||||
|
||||
void LQML::eval(const QString& lisp_code, bool slime) {
|
||||
if (slime) {
|
||||
safe_eval_debug(lisp_code.toLatin1().constData());
|
||||
} else {
|
||||
cl_object ret = safe_eval(lisp_code.toLatin1().constData());
|
||||
if (ecl_t_of(ret) == t_fixnum && (fix(ret) == EVAL_ERROR_VALUE)) {
|
||||
qDebug() << "Error evaluating " << lisp_code;
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public:
|
|||
static const char version[];
|
||||
static QEventLoop* eventLoop;
|
||||
static void ini(int, char* []);
|
||||
static void eval(const QString&);
|
||||
static void eval(const QString&, bool = false);
|
||||
static LQML* me;
|
||||
static QQuickView* quickView;
|
||||
|
||||
|
|
|
|||
|
|
@ -68,15 +68,26 @@ int main(int argc, char* argv[]) {
|
|||
LQML::eval("(x:when-it (probe-file \"~/.eclrc\") (load x:it))");
|
||||
}
|
||||
|
||||
bool slime = false;
|
||||
if (arguments.contains("-slime")) {
|
||||
arguments.removeAll("-slime");
|
||||
slime = true;
|
||||
}
|
||||
|
||||
// load Lisp file
|
||||
if (arguments.length() > 1) {
|
||||
QString arg1(QDir::fromNativeSeparators(arguments.at(1)));
|
||||
if (arg1.endsWith(".lisp")) {
|
||||
LQML::eval(QString("(load \"%1\")").arg(arg1));
|
||||
//LQML::eval("(loop (with-simple-restart (restart-qt-events \"Restart Qt event processing.\") (qexec)))");
|
||||
}
|
||||
}
|
||||
|
||||
if (slime) {
|
||||
LQML::eval("(loop (with-simple-restart (restart-qt-events \"Restart Qt event processing.\") (qexec)))",
|
||||
true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return catch_all_qexec();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue