Bug 407925

Summary: new check: directly calling a method on a QObject after it has been moved to another thread
Product: [Developer tools] clazy Reporter: d3fault
Component: generalAssignee: Unassigned bugs <unassigned-bugs-null>
Status: REPORTED ---    
Severity: wishlist CC: smartins
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

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.