On Fri, Jun 24, 2022, at 12:50, Ulf Hermann wrote:
>> Right, normally when evaluating a script, any error can be caught and 
>> reported however you wish, but this does not work when the script execution 
>> is trigger through a signal connection. In this case, when using QJSEngine, 
>> errors are always printed to the standard out, whereas the QQmlEngine allows 
>> reporting these through its "warnings" signal.
>
> Well, I would like to see a bug report with a minimal reproducer for 
> this. How do you produce a signal connection in pure JS?

You just expose a QObject-derived class instance to JS which has a signal, and 
then in JS you can do:

    someObject.someSignal.connect(() => {});

See 
https://doc.qt.io/qt-6.2/qtqml-syntax-signals.html#connecting-signals-to-methods-and-signals

But if you trigger a runtime error, like:

    someObject.someSignal.connect(() => {
        FooDoesNotExist.Bar;
    });

And then emit "someSignal" from C++, then the connected JS function gets 
executed, but without any way of catching and reporting the resulting error, 
unless you use QQmlEngine and connect to the "warnings" signal.

Cheers,
Thorbjørn
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to