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-b...@kde.org
          Reporter: dism...@gmail.com
                CC: smart...@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 watching all bug changes.

Reply via email to