entry-directories: don't modify a list while iterating it

cached_dir_unref() tries to remove the directory from the parent's
list of subdirectories, but it is also called when the parent is
being freed and iterating with foreach() on its directory list.
This is unsafe, so don't do it.
Also, fix the logic for remove_subdir() to unref() only when it's
right to do so (ie, always, when the function is called, because
everything keeps strong references).

https://bugzilla.gnome.org/show_bug.cgi?id=720460
entry-directories: protect event handling for directories

If a new desktop file is created or deleted in a monitored directory,
the desktop cache is cleared completely, and the CachedDir structure
is freed, which causes a segfault. Protect it as long as the new
event is queued and later handled.

https://bugzilla.gnome.org/show_bug.cgi?id=720460