Only call graphics handler when there is graphical output to process

Otherwise every graphics handler function has to start with a check for NULL.