[gnumeric] GnmApplication: don't allocate a GtkRecentManager unless we have a display.



commit 19a551d19f27f5f8d70a0e0e3f91cf66d17e39e0
Author: Morten Welinder <terra gnome org>
Date:   Sat Dec 7 15:07:51 2013 -0500

    GnmApplication: don't allocate a GtkRecentManager unless we have a display.
    
    We get a critical deep inside gtk+ for that.

 ChangeLog         |    3 +++
 src/application.c |   26 +++++++++++++++++++++-----
 2 files changed, 24 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a0f4f93..26ae6f8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2013-12-07  welinder  <terra gnome org>
 
+       * src/application.c (gnm_app_init): Don't allocate a
+       GtkRecentManager if we are not in gui mode.
+
        * src/position.c (gnm_cellref_hash): Avoid undefined signed integer
        behaviour.
        * src/dependent.c (deprange_hash): Ditto.
diff --git a/src/application.c b/src/application.c
index 3feb684..33ed7eb 100644
--- a/src/application.c
+++ b/src/application.c
@@ -595,12 +595,17 @@ gnm_app_history_get_list (int max_elements)
 {
        GSList *res = NULL;
        GList *items, *l;
-       GtkFileFilter *filter = gnm_app_create_opener_filter (NULL);
+       GtkFileFilter *filter;
        int n_elements = 0;
 
+       if (app->recent == NULL)
+               return NULL;
+
        items = gtk_recent_manager_get_items (app->recent);
        items = g_list_sort (items, (GCompareFunc)compare_mru);
 
+       filter = gnm_app_create_opener_filter (NULL);
+
        for (l = items; l && n_elements < max_elements; l = l->next) {
                GtkRecentInfo *ri = l->data;
                const char *uri = gtk_recent_info_get_uri (ri);
@@ -654,6 +659,9 @@ gnm_app_history_add (char const *uri, const char *mimetype)
 {
        GtkRecentData rd;
 
+       if (app->recent == NULL)
+               return;
+
        memset (&rd, 0, sizeof (rd));
 
 #if 0
@@ -1402,10 +1410,18 @@ gnm_app_init (GObject *obj)
 
        gnm_app->workbook_list = NULL;
 
-       gnm_app->recent = gtk_recent_manager_get_default ();
-       g_signal_connect_object (G_OBJECT (gnm_app->recent),
-                                "changed", G_CALLBACK (cb_recent_changed),
-                                gnm_app, 0);
+       if (gdk_display_get_default ()) {
+               /*
+                * Only allocate a GtkRecentManager if we have a gui.
+                * This is, in part, because it currently throws an error.
+                * deep inside gtk+.
+                */
+               gnm_app->recent = gtk_recent_manager_get_default ();
+               g_signal_connect_object (G_OBJECT (gnm_app->recent),
+                                        "changed",
+                                        G_CALLBACK (cb_recent_changed),
+                                        gnm_app, 0);
+       }
 
        app = gnm_app;
 }


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