Fix bug: crash - iterator corrupted by removing objects from container

Merged username-removed-1661829 requested to merge fredowski/inkscape:master into master

On MacOS El Capitan with XCode 7.3 inkscape crashes when a second item is drawn in the drawing area. The crash is triggered by clearing the selection from the previous drawing activity. The reason for the crash is that the iterator is corrupted because during iteration the objects are removed from the container.

This patch uses a safe way to remove items from the container and going to the next iteration. Using this patch, inkscape does not crash anymore.