[bijiben] application: Import notes only when manager is ready



commit 44ffaa3cb16da4b8114796482a8dd7b968a079c8
Author: Mohammed Sadiq <sadiq sadiqpk org>
Date:   Thu Dec 21 19:58:43 2017 +0530

    application: Import notes only when manager is ready
    
    The notes from tomboy and gnote where being imported before
    the manager was ready. As this is not possible, the user was
    welcome with a segfault instead.
    
    So, import the notes only after the manager is ready, and test
    for the import paths before importing.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=783471

 src/bjb-application.c |   36 +++++++++++++++++++-----------------
 1 files changed, 19 insertions(+), 17 deletions(-)
---
diff --git a/src/bjb-application.c b/src/bjb-application.c
index 7ba003e..e9033c6 100644
--- a/src/bjb-application.c
+++ b/src/bjb-application.c
@@ -254,6 +254,7 @@ manager_ready_cb (GObject *source,
 {
   BjbApplication *self = user_data;
   GError *error = NULL;
+  gchar *path, *uri;
 
   self->manager = biji_manager_new_finish (res, &error);
   g_application_release (G_APPLICATION (self));
@@ -265,6 +266,24 @@ manager_ready_cb (GObject *source,
       return;
     }
 
+  /* Automatic imports on startup */
+  if (self->first_run == TRUE)
+    {
+      path = g_build_filename (g_get_user_data_dir (), "tomboy", NULL);
+      uri = g_filename_to_uri (path, NULL, NULL);
+      if (g_file_test (path, G_FILE_TEST_EXISTS))
+        bijiben_import_notes (self, uri);
+      g_free (path);
+      g_free (uri);
+
+      path = g_build_filename (g_get_user_data_dir (), "gnote", NULL);
+      uri = g_filename_to_uri (path, NULL, NULL);
+      if (g_file_test (path, G_FILE_TEST_EXISTS))
+        bijiben_import_notes (self, uri);
+      g_free (path);
+      g_free (uri);
+    }
+
   bijiben_new_window_internal (self, NULL);
 }
 
@@ -275,7 +294,6 @@ bijiben_startup (GApplication *application)
   gchar          *storage_path, *default_color;
   GFile          *storage;
   GError         *error;
-  gchar          *path, *uri;
   GdkRGBA         color = {0,0,0,0};
 
 
@@ -313,22 +331,6 @@ bijiben_startup (GApplication *application)
   g_application_hold (application);
   biji_manager_new_async (storage, &color, manager_ready_cb, self);
 
-  /* Automatic imports on startup */
-  if (self->first_run == TRUE)
-  {
-    path = g_build_filename (g_get_user_data_dir (), "tomboy", NULL);
-    uri = g_filename_to_uri (path, NULL, NULL);
-    bijiben_import_notes (self, uri);
-    g_free (path);
-    g_free (uri);
-
-    path = g_build_filename (g_get_user_data_dir (), "gnote", NULL);
-    uri = g_filename_to_uri (path, NULL, NULL);
-    bijiben_import_notes (self, uri);
-    g_free (path);
-    g_free (uri);
-  }
-
   g_free (default_color);
   g_free (storage_path);
   g_object_unref (storage);


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