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.