This should use the
```
if (obj->foo != NULL) {
  g_object_unref(obj->foo);
  obj->foo = NULL;
}
```
paradigm (or `g_clear_object`), as you're in a dispose handler which can be called twice on the same instance.