[GTK4] GtkPopover Finalizing warning

The short answer is: you cannot add a GtkPopover to random widgets and expect it to work.

If you want to add a GtkPopover to a GtkButton you will need to:

  1. create a new class that inherits from GtkButton
  2. create a new GtkPopover instance inside the instance initialisation function of your derived button class, and keep a reference to it: button->popover = gtk_popover_new()
  3. call gtk_widget_set_parent(button->popover, button) inside the instance initialisation function of your derived button class
  4. override GObjectClass.dispose and call gtk_widget_unparent(button->popover) inside the dispose implementation

For more information on how to derive GObject types like GtkWidget, you should read the GObject tutorial.