Fix memory leak (reviewed and tested by Laurent)

1 job for master in 18 minutes and 6 seconds (queued for 3 seconds)
Status Job ID Name Coverage
  Build
passed #53461
linux kf5-qt5 qt5.12

00:18:06

1.0%