[glib: 2/2] Merge branch 'ebassi/floating-warning' into 'main'




commit 579ff9f6c9aa0b84df2d14634523601297807d7d
Merge: bbd1350be 6fe0f9836
Author: Philip Withnall <philip tecnocode co uk>
Date:   Tue Sep 21 11:09:16 2021 +0000

    Merge branch 'ebassi/floating-warning' into 'main'
    
    Add a (diagnostic) warning for finalized floating objects
    
    Closes #2489
    
    See merge request GNOME/glib!2247

 gobject/gobject.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
---
diff --cc gobject/gobject.c
index 9ddab43f0,2d950a687..c05de431e
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@@ -1179,9 -1178,26 +1179,27 @@@ g_object_real_dispose (GObject *object
    g_signal_handlers_destroy (object);
    g_datalist_id_set_data (&object->qdata, quark_closure_array, NULL);
    g_datalist_id_set_data (&object->qdata, quark_weak_refs, NULL);
 +  g_datalist_id_set_data (&object->qdata, quark_weak_locations, NULL);
  }
  
+ static gboolean
+ floating_check (GObject *object)
+ {
+   static const char *g_enable_diagnostic = NULL;
+ 
+   if (G_UNLIKELY (g_enable_diagnostic == NULL))
+     {
+       g_enable_diagnostic = g_getenv ("G_ENABLE_DIAGNOSTIC");
+       if (g_enable_diagnostic == NULL)
+         g_enable_diagnostic = "0";
+     }
+ 
+   if (g_enable_diagnostic[0] == '1')
+     return g_object_is_floating (object);
+ 
+   return FALSE;
+ }
+ 
  static void
  g_object_finalize (GObject *object)
  {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]