Skip to content
Commit 39c665c9 authored by Milian Wolff's avatar Milian Wolff
Browse files

Revamp lifetime management of CollectionExecuteWrapper

Instead of relying on the cleanup function being called after the
job was run, let the job own the executor and then delete the
executor alongside the job. This way, we also properly cleanup the
resources for dequeued elements. Furthermore, we properly cleanup
the resources for nested wrapped executors now, which was not handled
properly previously either. Fixes a ton of memory leaks in the unit
tests, such as:

```
Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7f66160e2002 in operator new(unsigned long) /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_new_delete.cpp:95
    #1 0x7f6615ac5cde in ThreadWeaver::Collection::addJob(QSharedPointer<ThreadWeaver::JobInterface>) /home/milian/projects/kde/src/frameworks/threadweaver/src/collection.cpp:54
    #2 0x561dff4046f1 in JobTests::QueueAndDequeueCollectionTest() /home/milian/projects/kde/src/frameworks/threadweaver/autotests/JobTests.cpp:391

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7f12d16e2002 in operator new(unsigned long) /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_new_delete.cpp:95
    #1 0x7f12d10c6dbe in ThreadWeaver::Collection::addJob(QSharedPointer<ThreadWeaver::JobInterface>) /home/milian/projects/kde/src/frameworks/threadweaver/src/collection.cpp:54
    #2 0x55e5e2ca7519 in JobTests::RecursiveQueueAndDequeueAllCollectionTest() /home/milian/projects/kde/src/frameworks/threadweaver/autotests/JobTests.cpp:613
```
parent b26d1f03
Pipeline #484931 passed with stage
in 5 minutes and 3 seconds
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment