gdbus-codegen: Don't send out PropertiesChanged if value ends up not changing
authorDavid Zeuthen <davidz@redhat.com>
Fri, 15 Apr 2011 19:53:28 +0000 (15:53 -0400)
committerDavid Zeuthen <davidz@redhat.com>
Fri, 15 Apr 2011 19:53:28 +0000 (15:53 -0400)
commit6bccc46d152079d69cf8aebef08433b1ec6055c7
treebd8671b024131a0bfe7eaaf4d144f7b39eeeabd7
parentcade3cb1dab58ee0ab291efbab03e5b047b2a5be
gdbus-codegen: Don't send out PropertiesChanged if value ends up not changing

A fairly typical pattern is to have code that does

 foo_set_bar (object, "");
 if (some_condition)
   {
     foo_set_bar (object, "yes");
   }

where some_condition is often true every time @object is updated.

With this code, bar is essentially always "yes" but because of how
gdbus-codegen works, useless PropertiesChanged events got scheduled
and sent out. With this patch, we avoid that by always keeping the
original value around and comparing it only when we deem it's time to
send out the ::PropertiesChanged signal (typically in an idle but can
be forced by the user via flush()).

Also add a test case for this.

Signed-off-by: David Zeuthen <davidz@redhat.com>
gio/gdbus-codegen/codegen.py
gio/tests/gdbus-test-codegen.c
gio/tests/test-codegen.xml