Bug 407925 - new check: directly calling a method on a QObject after it has been moved to another thread
Summary: new check: directly calling a method on a QObject after it has been moved to ...
Status: REPORTED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Unassigned bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-25 04:28 UTC by d3fault
Modified: 2019-05-25 04:28 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description d3fault 2019-05-25 04:28:24 UTC
After a call to moveToThread, that object pointer shouldn't be used to directly call any methods, except thread-safe ones such as deleteLater. invokeMethod should be used instead.

A fixit could be provided which automatically converts the direct method calls to invokeMethod calls, preferably using the new pmf/lambda invokeMethod overload.


More generally we could flag and offer a fixit for _any_ direct call to a QObject's method, not just calls that occur after a moveToThread. It's good to always write thread-safe code. See QTCREATORBUG-15972 for the inspiration of this suggestion.