If ContactPreferences are set explitly and not loaded via Akonadi this function cannot lock. So it is safe to move the #if.
mentioned in commit 262aedf4