Fix a number of bugs uncovered by a recent leak fix (ff5b33b82b).

To name just a few:
    - Product removal, adaptation and re-resolving/swapping build data
was done in the wrong order, resulting in outdated information still
being present and necessary new one not being there yet.
    - Outdated artifacts were deleted too early, so that look-ups into
the old project build data would cause undefined behavior.
    - The list of products whose file list was changed could contain the
same entry twice, causing asserts when the same code was run again for
the same product.

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