Don't set dirty flag if the preference value does not change.

This fixes #7063 by not writing out no-op changes to disk.