[Development] Disabling exception support in QtCore?

Olivier Goffart olivier at woboq.com
Thu Oct 3 10:36:44 CEST 2013


On Wednesday 02 October 2013 09:30:58 Thiago Macieira wrote:
> On quarta-feira, 2 de outubro de 2013 07:13:11, Knoll Lars wrote:
> > +1. It's our decision not to use exceptions in Qt code, but I see quite a
> > bit of value in being able to throw exceptions from a slot if that's the
> > pattern a developer chooses to use. We've been doing quite a bit of work
> > to allow this in Qt 4, and it's the main place where exception safety in
> > Qt Core really makes sense IMO.
> 
> Then please clarify the semantics. I really don't see this as a currently-
> valid use-case because it's not been specified.
> 
> I dislike allowing this via the signal-slot mechanism because I see throwing
> from a slot as incompatible with the connection semantics. 

> That would mean any signal could throw ANY exception. It would also preempt
> the execution of further slots, which might be important.
> 
> Usually the person who connects a signal to a slot is a completely different
> developer than who wrote the signal or the slot. 

I think your assumptions are false.
When using signals and slot in an application one write both the signal and 
the slot at the same time, to wire two part of that same appliation.

> That would mean people who do connections should have to pay attention to
> what slots throw and know what signals can cope with exceptions being
> thrown.

Signals and slots are not different from normal functions in that respect 
(especially virtual functions)
One need to take care who calls your function when you throw exceptions.

> I would accept at most exceptions through the invokeMethod mechanism in a
> DirectConnection, since that's a 1:1 relationship and there are no signals.

-- 
Olivier

Woboq - Qt services and support - http://woboq.com - http://code.woboq.org




More information about the Development mailing list