Extend --no-try-catch to catching of C++ exceptions in Qt scripts

This commit is contained in:
Laurent Rineau 2016-12-02 12:04:47 +01:00
parent fd355aaf06
commit 847906e2e4
2 changed files with 4 additions and 1 deletions

View File

@ -100,6 +100,7 @@ Polyhedron_demo::~Polyhedron_demo() {}
void Polyhedron_demo::do_not_catch_exceptions() {
d_ptr->catch_exceptions = false;
setProperty("no-try-catch", true);
}
bool Polyhedron_demo::notify(QObject* receiver, QEvent* event)

View File

@ -23,6 +23,7 @@
#include <exception>
#include <QString>
#include <QApplication>
#include <QScriptable>
#include <QScriptContext>
#include <QScriptEngine>
@ -81,7 +82,8 @@ wrap_a_call_to_cpp(Callable f,
typedef Optional_or_bool<Callable_RT> O_r_b;
typedef typename O_r_b::type Return_type;
if(qs == 0 || !qs->context()) return O_r_b::invoke(f);
const bool no_try_catch = qApp->property("no-try-catch").toBool();
if(no_try_catch || qs == 0 || !qs->context()) return O_r_b::invoke(f);
else
try {
return O_r_b::invoke(f);