Make fundamental types deep-derivable
@mitch
Submitted by Michael Natterer Assigned to Tim Janik
Link to original bug (#375864)
Description
In GIMP, we have a hierarchy of objects:
- GimpItem
+-GimpDrawable
| +-GimpChannel
| +-GimpLayer
+-GimpVectors
And all these objects have integer IDs, which is how we pass them to plug-ins, which live in separate processes.
They are passed as GValues, each described by a GParamSpec. There is a GParamSpec for each of the above objects' integer ID, so it can be properly validated. The param specs have the same type hierarchy as above objects.
However the GTypes created for the IDs themselves DON'T have this hierarchy, they are all derived from G_TYPE_INT, because deep derivation is not possible for fundamental types.
So if we want to write some generic code that operates on GValues that hold GimpItem IDs, even tho the passed in GValues in fact contain a GimpLayer ID or a GimpVectors ID, it just won't work to do it properly because e.g. GIMP_VALUE_HOLDS_ITEM_ID() fails on something that holds in fact a GimpLayer ID.
I also recally a case from a mailing list (don't find it currently) where people wanted to properly type "hash table of strings" and "hash table of foo" and still want to be able to treat the GTypes as TYPE_HASH_TABLE.
I think there is no good reason to forbid deep-derivation on fundamental types, it's in fact in severe restriction on applications which use the GType system in a non-trivial way.