Property deprecation warning can be issued in cases when deprecated property isn't used
This is a bit of a confusing case. I ran into it while building GJS with GLib as a subproject, and I believe it's because !2889 (merged) somehow puts G_ENABLE_DIAGNOSTICS=1
into the parent project's test environment. (That's not the bug I'm reporting here, I'm not sure it's even a bug or just generally Meson's intentional lack of isolation between subprojects and parent projects.)
If you override a class's constructor
vfunc and chain up, then you will get property deprecation warnings for all construct properties in the inheritance chain that are deprecated.
Here's an example (excuse the GTK 3, GtkButton:use-stock
was the first deprecated property that came to mind)
// compile: gcc -o bug bug.c $(pkg-config --cflags --libs gobject-2.0 gtk+-3.0)
// run: G_ENABLE_DIAGNOSTIC=1 ./bug
#include <glib-object.h>
#include <gtk/gtk.h>
typedef struct {
GtkButton parent;
} MyWidget;
typedef struct {
GtkButtonClass parent_class;
} MyWidgetClass;
static GObject *constructor(GType type, unsigned n_construct_props, GObjectConstructParam *construct_props) {
return G_OBJECT_CLASS(g_type_class_peek(GTK_TYPE_BUTTON))->constructor(type, n_construct_props, construct_props);
}
static void my_widget_class_init(MyWidgetClass *class_pointer) {
GObjectClass* oc = G_OBJECT_CLASS(class_pointer);
oc->constructor = constructor;
}
static void my_widget_init(MyWidget *self) {}
G_DEFINE_TYPE(MyWidget, my_widget, GTK_TYPE_BUTTON)
int main(int argc, char *argv[]) {
gtk_init(&argc, &argv);
g_object_new(my_widget_get_type(), NULL);
}
Output:
(bug:75): GLib-GObject-WARNING **: 11:22:52.946: The property GtkButton:use-stock is deprecated and shouldn't be used anymore. It will be removed in a future version.
This warning is confusing because the property isn't actually used anywhere and there's nothing actionable for the writer of this code.
The properties passed to the construct vfunc are filled in here: https://gitlab.gnome.org/GNOME/glib/-/blob/main/gobject/gobject.c?ref_type=heads#L2484-2518
Maybe that code should skip initializing deprecated construct properties, or user_specified
should be expanded to cover the case when chaining up in constructor
.