[Development] QtCS - QtCore discussion
Thiago Macieira
thiago.macieira at intel.com
Thu Aug 22 17:59:49 CEST 2013
On quinta-feira, 22 de agosto de 2013 16:44:53, Olivier Goffart wrote:
> As far as I am concerned, throwing an exception from a slot which is
> connected with a DirrectConnection to the signal should work. The
> exception is propagated to the signal and if there was more slot connected,
> further slot would not be called.
>
> At least it used to work. But Thiago has been against officially supporting
> it, and removed it from the documentation. Also that is not very well
> tested.
>
> See the discussion in this doc
> patch https://codereview.qt-project.org/41179
If you have patches fixing this support, I might accept them. But I do not want
to make it officially supported.
>
> > Generally, I assume it's OK for a developer using Qt to throw exceptions.
> > But at what point is he required to catch? What are the guidelines here?
> > Must he ensure that no exceptions are thrown across Qt functions? I.e.
> > never throw from a slot? I'd welcome if this could be clearly communicated
> > somewhere in the documentation. People will use exceptions and they will
> > run into problems when using Qt, so this must be clarified imo.
>
> I guess the new policy should be:
> "Don't let exceptions cross Qt boundaries"
Right. You should assume that all of Qt code is compiled without exception
support. If you let any exception propagate into Qt code, you'll be in
undefined behaviour territory.
In specific:
* Qt never runs out of memory
* you can use exceptions in your own code to your heart's content
* you can let your slots throw exceptions, provided that the slot was not
called by the Qt meta-object system (invokeMethod or signal-slot
connection)
* contained types in the containers must not throw on creation, copy, move,
destruction, comparison, sorting (QMap) or hashing (QHash).
--
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/20130822/cd27e88e/attachment.sig>
More information about the Development
mailing list