Bug 403394 - Warn about missed override of helper functions for QException descendants
Summary: Warn about missed override of helper functions for QException descendants
Status: REPORTED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Sergio Martins
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-19 12:22 UTC by Roman
Modified: 2019-02-15 22:57 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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