[Interest] Where to catch exception when a qml plugin is loaded? Even possible?
wargand at gmx.de
wargand at gmx.de
Thu Apr 26 02:04:27 CEST 2012
> First of all, you should almost always avoid throwing anything from
> a constructor. Scott Meyers has an item in More Effective C++ about
> why it's a bad idea.
Naaaa, throwing from a constructor is fine. Throwing from a destructor
is a big no no. Actually there is no other way to cleanly 'get out'
when construction fails.
> Second, you can *never* do it in that case. The only place you can
> put that catch is just before the return in main. It will screw up
> everything.
That I am afraid, is true. Especially since there is no main in this
case. ;-)
> Don't do it.
Don't worry, I want to, but I can't ;-)
Guido
> Bo.
>
> Den 25-04-2012 21:19, wargand at gmx.de skrev:
>
> > I have a QDeclarativeExtensionPlugin, which registers a class
> > ImageModel to be used as model in QML. Works fine (see snippet
> > below).
> >
> > Now I am wondering, ist is possible to throw an exception in the
> > ImageModel's contructor? Ok, it is possible, but is it possible to
> > catch it? Where is ImageModel actually instantiated and do I have
> > a chance to wrap my try/catch around it?
> >
> > Guido
> >
> >
> > void ImagePlugin::registerTypes(const char *uri) {
> > qmlRegisterType<ImageModel>(uri, 1, 0, "ImageModel"); }
> >
> > Q_EXPORT_PLUGIN2(imageplugin, ImagePlugin)
> > __________________________________________________________________
> > Interest mailing list Interest at qt-project.org
> > http://lists.qt-project.org/mailman/listinfo/interest
>
>
> Bo Thorsen, Fionia Software.
>
> --
>
> Expert Qt and C++ developer for hire Contact me if you need expert
> Qt help http://www.fioniasoftware.dk
> ____________________________________________________________________
> Interest mailing list Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
More information about the Interest
mailing list