if contents is NULL, calling contents->getGraphicsHeight() will crash. The same in few next places