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 ```
Please register or sign in to comment