[gnome-builder/wip/libide-merge] libide: ignore non-modified buffers during unload



commit bf6956fedadfcb20fe999e1c522b6b0c41c433df
Author: Christian Hergert <christian hergert me>
Date:   Mon Mar 23 03:25:51 2015 -0700

    libide: ignore non-modified buffers during unload
    
    We do the ugly object get/(re)set hack just in case things got mutated
    in between. Perhaps a g_new0(int,1) with set_data_full() would be more
    appropriate.

 libide/ide-context.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-context.c b/libide/ide-context.c
index 33779b5..2709b6a 100644
--- a/libide/ide-context.c
+++ b/libide/ide-context.c
@@ -1297,6 +1297,7 @@ ide_context_unload_buffer_manager (gpointer             source_object,
   g_autoptr(GTask) task = NULL;
   g_autoptr(GPtrArray) buffers = NULL;
   gsize i;
+  guint skipped = 0;
 
   IDE_ENTRY;
 
@@ -1315,6 +1316,13 @@ ide_context_unload_buffer_manager (gpointer             source_object,
 
       buffer = g_ptr_array_index (buffers, i);
       file = ide_buffer_get_file (buffer);
+
+      if (!gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (buffer)))
+        {
+          skipped++;
+          continue;
+        }
+
       ide_buffer_manager_save_file_async (self->buffer_manager,
                                           buffer,
                                           file,
@@ -1324,6 +1332,18 @@ ide_context_unload_buffer_manager (gpointer             source_object,
                                           g_object_ref (task));
     }
 
+  if (skipped > 0)
+    {
+      guint count;
+
+      count = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (task), "IN_PROGRESS"));
+      count -= skipped;
+      g_object_set_data (G_OBJECT (task), "IN_PROGRESS", GINT_TO_POINTER (count));
+
+      if (count == 0)
+        g_task_return_boolean (task, TRUE);
+    }
+
   IDE_EXIT;
 }
 


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