[prefs] Handle weak references correctly
[prefs] Handle weak references correctly

When an observer is added as a weak reference the object may disappear
at any time. Therefore we should check whether the object is still
alive before calling its notify method.

The code to remove an observer has been separated out into an internal
function that can remove it given the index in the array. The
notification method uses this to remove a weak observer from the list
if it has disappeared.

This fixes a crash caused when the browser clears all preferences.

clutter-project/clutter-mozembed,clutter-project/clutter-mozembed,clutter-project/clutter-mozembed