Marc-André Lureau <marcandre.lur...@redhat.com> writes: > Hi, > > This series aims to get rid of the distinction between QObject, that > must use qobject_incref/qobject_decref and its various derived types > that have to use QINCREF/QDECREF. Instead, replace it with > qobject_ref/qobject_unref for all types.
This is a lovely improvement. However, I think the code can't quite decide whether to embrace or eschew type casts between QObject and its subtypes. On the one hand, we provide safe conversion macros QOBJECT() and qobject_to(). By the way, shouting one but not the other is a bit ugly. On the other hand, we still use type casts, and enforce "base comes first" to make them work. If we want to eschew type casts, we should clean up the remaining ones. The case for "base must come first" is quite weak then. Not worth the bother, I think. I doubt we want to embrace type casts here. If we wanted to, I'd go all the way and unwrap base in QObjects and its subtypes with suitable "must match QObject" comments. Alternatively, use an unnamed member. Then convert with type casts rather than container_of() and &->base.