This is a similar situation to https://github.com/Freeseer/freeseer/pull/413/files#r8172581, so perhaps this method can be combined with the above.