Fix crash when opening generic project

target t is deleted inside removeTarget(t)

Change-Id: I9d5a07d65a2cb0c47869edf3997a44a526b9930e
Reviewed-by: Orgad Shaneh <orgads@gmail.com>