1bf58212de49e90cf6d4f047ea4000c876f06d43
diff --git a/gtk/gtkrecentchooserdefault.c b/gtk/gtkrecentchooserdefault.c
index cf7254b..40d600b 100644
--- a/gtk/gtkrecentchooserdefault.c
+++ b/gtk/gtkrecentchooserdefault.c
@@ -601,7 +601,7 @@ gtk_recent_chooser_default_dispose (GObject *object)
       impl->recent_items = NULL;
     }
 
-  if (impl->manager_changed_id)
+  if (impl->manager && impl->manager_changed_id)
     {
       g_signal_handler_disconnect (impl->manager, impl->manager_changed_id);
       impl->manager_changed_id = 0;
@@ -1833,13 +1833,26 @@ recent_view_button_press_cb (GtkWidget      *widget,
 }
 
 static void
+recent_manager_weak_cb (gpointer  user_data,
+                        GObject  *object)
+{
+  GtkRecentChooserDefault *impl = user_data;
+
+  impl->manager = NULL;
+  impl->manager_changed_id = 0;
+}
+
+static void
 set_recent_manager (GtkRecentChooserDefault *impl,
 		    GtkRecentManager        *manager)
 {
   if (impl->manager)
     {
-      g_signal_handler_disconnect (impl, impl->manager_changed_id);
-      impl->manager_changed_id = 0;
+      if (impl->manager_changed_id)
+        {
+          g_signal_handler_disconnect (impl, impl->manager_changed_id);
+          impl->manager_changed_id = 0;
+        }
 
       impl->manager = NULL;
     }
@@ -1850,9 +1863,21 @@ set_recent_manager (GtkRecentChooserDefault *impl,
     impl->manager = gtk_recent_manager_get_default ();
   
   if (impl->manager)
-    impl->manager_changed_id = g_signal_connect (impl->manager, "changed",
-      						 G_CALLBACK (recent_manager_changed_cb),
-      						 impl);
+    {
+      impl->manager_changed_id = g_signal_connect (impl->manager, "changed",
+                                                   G_CALLBACK (recent_manager_changed_cb),
+                                                   impl);
+      
+      /* we need to keep a weak reference on the manager in the
+       * offchance that it's the recent manager singleton that
+       * gtk_recent_manager_get_default() returns, and the user
+       * destroyes the widget after gtk_main_quit(), where the
+       * singleton is finalized.
+       */
+      g_object_weak_ref (G_OBJECT (impl->manager),
+                         recent_manager_weak_cb,
+                         impl);
+    }
 }
 
 GtkWidget *
