Avoid access to ImageDB::instance() from within Database constructor.
This commit does the following things (not ideal, but I currently don't
intend working on it any further):
- delay merging the duplicate image infos until all images have been
read (i.e. prevent inconsistencies when merging stacks)
- move ImageInfo::merge() into XMLDB (preventing the need to access the
ImageDB singleton before it's initialized)
- Avoid any direct or indirect access to ImageInfo::instance in the
whole of XMLDB::Database (especially in the stack manipulation methods),
so that it is safe to call them during construction.
Probably I still overlooked something because with my test data the
stack merging spiraly into an out-of-memory situation.