[gnome-builder] buffer-manager: add IdeBufferManager::buffer-unloaded



commit 5c84f4e6ed53d38b2b27d126ddf435486b108f95
Author: Christian Hergert <chergert redhat com>
Date:   Thu Oct 20 19:55:17 2016 -0700

    buffer-manager: add IdeBufferManager::buffer-unloaded
    
    This signal is emitted right before a buffer is unloaded. It should only
    be used to perform cleanup operations to be synchronous with buffer-loaded.

 libide/buffers/ide-buffer-manager.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/libide/buffers/ide-buffer-manager.c b/libide/buffers/ide-buffer-manager.c
index 695232b..5ff1b5b 100644
--- a/libide/buffers/ide-buffer-manager.c
+++ b/libide/buffers/ide-buffer-manager.c
@@ -107,6 +107,7 @@ enum {
 
   LOAD_BUFFER,
   BUFFER_LOADED,
+  BUFFER_UNLOADED,
 
   BUFFER_FOCUS_ENTER,
   BUFFER_FOCUS_LEAVE,
@@ -414,6 +415,12 @@ ide_buffer_manager_remove_buffer (IdeBufferManager *self,
                                         G_CALLBACK (ide_buffer_manager_buffer_changed),
                                         self);
 
+  /*
+   * Notify anything that needs a pointer to the buffer to cleanup,
+   * such as language server clients.
+   */
+  g_signal_emit (self, signals [BUFFER_UNLOADED], 0, buffer);
+
   /* Try hard to ensure the buffer releases any objects held.
    * That way, if for some reason the buffer does get leaked
    * (which we see sometimes with GSV and have yet to track down),
@@ -1470,6 +1477,21 @@ ide_buffer_manager_class_init (IdeBufferManagerClass *klass)
                                                 G_TYPE_NONE,
                                                 1,
                                                 IDE_TYPE_BUFFER);
+
+  /**
+   * IdeBufferManager::buffer-unloaded:
+   * @self: An #IdeBufferManager
+   * @buffer: An #IdeBuffer
+   *
+   * This signal is emitted when the buffer is unloaded. This allows consumers to access the
+   * buffer before the items-changed signal is emitted for which it is too late to get
+   * a pointer to the buffer.
+   */
+  signals [BUFFER_UNLOADED] = g_signal_new ("buffer-unloaded",
+                                            G_TYPE_FROM_CLASS (klass),
+                                            G_SIGNAL_RUN_LAST,
+                                            0, NULL, NULL, NULL,
+                                            G_TYPE_NONE, 1, IDE_TYPE_BUFFER);
 }
 
 static void


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