[transfer-engine] Better attemp at fixing the QSqlDatabase leak

Don't ask me! I don't know why the code was written like that :S
I just want to fix the leak and postponing refactoring for now.