[clazy] [Bug 480491] New: Warn about QFutureWatcher::connect: connecting after calling setFuture().
Roman
bugzilla_noreply at kde.org
Mon Jan 29 14:30:16 GMT 2024
https://bugs.kde.org/show_bug.cgi?id=480491
Bug ID: 480491
Summary: Warn about QFutureWatcher::connect: connecting after
calling setFuture().
Classification: Developer tools
Product: clazy
Version: unspecified
Platform: Other
OS: Linux
Status: REPORTED
Severity: normal
Priority: NOR
Component: general
Assignee: unassigned-bugs at kde.org
Reporter: dismine at gmail.com
CC: smartins at kde.org
Target Milestone: ---
Hi.
Is there possible to catch with clazy this warning: QFutureWatcher::connect:
connecting after calling setFuture() is likely to produce race? This is
probably something new, since i never previously received such a warning. Here
is URL to Qt's code.
https://github.com/openwebos/qt/blob/92fde5feca3d792dfd775348ca59127204ab4ac0/src/corelib/concurrent/qfuturewatcher.cpp#L367
Here is an example of code that should trigger the warning.
MyClass myObject;
// Start the computation.
QFuture<int> future = QtConcurrent::run(...);
QFutureWatcher<int> watcher;
watcher.setFuture(future);
connect(&watcher, &QFutureWatcher<int>::finished, &myObject,
&MyClass::handleFinished);
According to documentation, correct code should look like this:
MyClass myObject;
QFutureWatcher<int> watcher;
connect(&watcher, &QFutureWatcher<int>::finished, &myObject,
&MyClass::handleFinished);
// Start the computation.
QFuture<int> future = QtConcurrent::run(...);
watcher.setFuture(future);
Clazy 1.11
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the Unassigned-bugs
mailing list