Fixed a NPE
Merge pull request #2600 from dominikl/rebased/develop/bug_12365

Fixed NPE (rebased onto develop)