Based on patch by dalerank, tested on Windows, might need to be amended for OSX. This was SVN commit r17870.
304a7c1201