Fix artifact leaks in build graph loader and automoc.

Change-Id: I989d88c58586ab9b6fe9f7870432f7266a00b9cc
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>