[gnome-builder] code: handle NULL buffer and boxing gracefully



commit d1bb13c3ce532739a15708eba9f5eec42b30b311
Author: Christian Hergert <chergert redhat com>
Date:   Fri Sep 11 12:29:59 2020 -0700

    code: handle NULL buffer and boxing gracefully
    
    We do a series of cleanups on the state object and we might have lost
    our connection to the object graph and or the buffer itself. This handles
    those situations gracefully (while still asserting correctness in devel
    builds).
    
    Fixes #1297

 src/libide/code/ide-buffer-manager.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/src/libide/code/ide-buffer-manager.c b/src/libide/code/ide-buffer-manager.c
index ecea05c57..9b75b0861 100644
--- a/src/libide/code/ide-buffer-manager.c
+++ b/src/libide/code/ide-buffer-manager.c
@@ -1078,11 +1078,15 @@ ide_buffer_manager_apply_edits_completed_cb (IdeBufferManager *self,
 
   while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&buffer))
     {
-      IdeObjectBox *box = ide_object_box_from_object (G_OBJECT (buffer));
+      if (buffer != NULL)
+        {
+          IdeObjectBox *box = ide_object_box_from_object (G_OBJECT (buffer));
 
-      g_assert (IDE_IS_OBJECT_BOX (box));
+          g_assert (!box || IDE_IS_OBJECT_BOX (box));
 
-      ide_object_destroy (IDE_OBJECT (box));
+          if (box != NULL)
+            ide_object_destroy (IDE_OBJECT (box));
+        }
     }
 
   IDE_EXIT;


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