Bug 403394

Summary: Warn about missed override of helper functions for QException descendants
Product: [Developer tools] clazy Reporter: Roman <dismine>
Component: generalAssignee: Sergio Martins <smartins>
Status: REPORTED ---    
Severity: wishlist CC: smartins
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Roman 2019-01-19 12:22:46 UTC
According to documentation for the QException class, Qt Concurrent supports throwing and catching exceptions across thread boundaries, provided that the exception inherit from QException and implement two helper functions.

class MyException : public QException
{
public:
    void raise() const override { throw *this; }
    MyException *clone() const override { return new MyException(*this); }
};

If such functions are not overridden in descendants, we can get unexpected behavior for exception thrown from a thread.
Comment 1 Sergio Martins 2019-02-15 19:22:19 UTC
Should they be pure virtual to begin with ?
Comment 2 Roman 2019-02-15 19:44:10 UTC
(In reply to Sergio Martins from comment #1)
> Should they be pure virtual to begin with ?

If you mean in QException class, i believe no, because QConcurrent need to throw something, but your code can just not expect QException, but something more specific.
Comment 3 Sergio Martins 2019-02-15 22:57:24 UTC
ok, makes sense