[Interest] Where to catch exception when a qml plugin is loaded? Even possible?
wargand at gmx.de
wargand at gmx.de
Thu Apr 26 10:38:52 CEST 2012
> Consider this line:
>
> Foo *foo = new Foo();
>
> Assuming 'new' succeeds and allocates memory on the heap: if the
> constructor throws, the pointer 'foo' never gets initialised.
> How do you cleanly 'get out' of that one? I.e. how do you delete
> the allocated memory without knowing where it is? If someone has a
> solution for this, I'll happily change my position!
Smart Pointer, RAII.....
Not a problem at all.
> Going back to Den's original post, that means he'd need to add an
> init method to ImageModel, and make sure it gets called when he
> wants to use the object.
Sorry, I did a boo boo and 'answered' the an exiting thread.
init method isn't a very good solution. The ImageModel is a C++ class,
which is used as plugin for QML. When I call init from QML, which
would be possible, I still would not be able to catch exception.
Currently I am investigating methods to determine and to act on
QML plugins when their construction fails.
Guido
More information about the Interest
mailing list