Fix #5789

Please see http://hub.qgis.org/issues/5789