[Development] Disabling exception support in QtCore?

Thiago Macieira thiago.macieira at intel.com
Thu Oct 3 19:38:59 CEST 2013


On quinta-feira, 3 de outubro de 2013 10:36:44, Olivier Goffart wrote:
> > 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's not at all true. If it were, we wouldn't have signals or slots in our 
public API. If people were supposed to write the signals and the slots they 
connect, all our signals and slots would be private.

Since we have public signals and public slots and other libraries do the same, 
it stands to reason that a third-party is expected to connect them. Moreover, 
it stands to reason that a third-party might connect a fourth-party slot to 
one of our (first-party) signals.

Said slot must not throw. Period.

> > 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 agree.

Which is why I am saying that we need to establish rules for when exceptions 
would be allowed to escape a slot.

Right now, our rule is: Qt code is noexcept. If your slot throws when called 
by Qt, the behaviour is undefined. If it throws when something else calls it, 
we make no statements.

If you want to change that rule, then we can discuss it.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20131003/2d3c9b66/attachment.sig>


More information about the Development mailing list