On 06/27/2011 08:26 AM, ext Дмитрий Б. wrote:
> Sorry guys if this question has already been discussed. Is any plans to
> make changes in Qt-API to be able to use C++ exceptions, as in the other
> frameworks?
> Like this:
>
> QThread* thread = new QThread();
> try
> {
> thread->start();
> }
> catch (e)
> {
> //Error, thread has not been created
> }
While this is a simple case (if you ignore abi quirks), consider this:
class MyWidget: public QWidget {
private:
void startStuff();
{
thread->start();
}
protected:
virtual void keyPressEvent ( QKeyEvent * event )
{
// if bla
startStuff();
}
}
What if start() throws now?
Where do you expect your "catch" ?
Either way, you can't unwind the eventloop. For once because that could
contain native calls that contain no unwind information.
To get reliable code, you will end up with this:
void startStuff();
{
try {
thread->start();
} catch(e) {
setError(e);
}
}
Which is exactly what Qt does in the first place, without the boilerplate.
_______________________________________________
Qt5-feedback mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback