Change order of API calls.

See https://bugreports.qt-
project.org/browse/QTBUG-35703?focusedCommentId=227124&page=com.atlassian.jira.plugin.system.issuetabpanels
:comment-tabpanel#comment-227124