Better handling of parent/child objets hierarchy

Refactoring a bit mainwindow class, trying to hunt down memory leaks.
Warns the user when opening a new mapfile