[gnome-builder] libide: only restore up to 20 files
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide: only restore up to 20 files
- Date: Fri, 24 Apr 2015 23:01:49 +0000 (UTC)
commit 98edc2156eae600ffb94be93bfbc08ff1d935855
Author: Christian Hergert <christian hergert me>
Date: Fri Apr 24 16:01:44 2015 -0700
libide: only restore up to 20 files
We can remove this later, but for a couple weeks we should have this.
Although, I'm not sure we are fast enough at loading gtkwidgets to
really handle over this anyway.
We need to adjust the number of popovers we use as well as listboxs.
libide/ide-context.c | 15 +++++++++++++++
libide/ide-unsaved-files.c | 21 +++++++++++++++++++++
libide/ide-unsaved-files.h | 1 +
3 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-context.c b/libide/ide-context.c
index 3470062..883fc4c 100644
--- a/libide/ide-context.c
+++ b/libide/ide-context.c
@@ -43,6 +43,8 @@
#include "ide-unsaved-files.h"
#include "ide-vcs.h"
+#define RESTORE_FILES_MAX_FILES 20
+
struct _IdeContext
{
GObject parent_instance;
@@ -1689,6 +1691,19 @@ ide_context_restore_async (IdeContext *self,
return;
}
+ if (ar->len > RESTORE_FILES_MAX_FILES)
+ {
+ /*
+ * To protect from some insanity, ignore attempts to restore files if
+ * they are over RESTORE_FILES_MAX_FILES. Just prune and go back to
+ * normal. This should help in situations where hadn't pruned the
+ * unsaved files list.
+ */
+ ide_unsaved_files_clear (self->unsaved_files);
+ g_task_return_boolean (task, TRUE);
+ return;
+ }
+
self->restoring = TRUE;
g_task_set_task_data (task, g_ptr_array_ref (ar), (GDestroyNotify)g_ptr_array_unref);
diff --git a/libide/ide-unsaved-files.c b/libide/ide-unsaved-files.c
index c500e1c..4bdca49 100644
--- a/libide/ide-unsaved-files.c
+++ b/libide/ide-unsaved-files.c
@@ -636,3 +636,24 @@ ide_unsaved_files_init (IdeUnsavedFiles *self)
priv->unsaved_files = g_ptr_array_new_with_free_func (unsaved_file_free);
}
+
+void
+ide_unsaved_files_clear (IdeUnsavedFiles *self)
+{
+ g_autoptr(GPtrArray) ar = NULL;
+ gsize i;
+
+ g_return_if_fail (IDE_IS_UNSAVED_FILES (self));
+
+ ar = ide_unsaved_files_to_array (self);
+
+ for (i = 0; i < ar->len; i++)
+ {
+ IdeUnsavedFile *uf;
+ GFile *file;
+
+ uf = g_ptr_array_index (ar, i);
+ file = ide_unsaved_file_get_file (uf);
+ ide_unsaved_files_remove (self, file);
+ }
+}
diff --git a/libide/ide-unsaved-files.h b/libide/ide-unsaved-files.h
index 03d3f71..595dd8a 100644
--- a/libide/ide-unsaved-files.h
+++ b/libide/ide-unsaved-files.h
@@ -55,6 +55,7 @@ GPtrArray *ide_unsaved_files_to_array (IdeUnsavedFiles *files
gint64 ide_unsaved_files_get_sequence (IdeUnsavedFiles *files);
IdeUnsavedFile *ide_unsaved_files_get_unsaved_file (IdeUnsavedFiles *self,
GFile *file);
+void ide_unsaved_files_clear (IdeUnsavedFiles *self);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]