r18911 - gnucash/trunk/src/import-export/csv - Partial fix for #611014 - CSV import crashes

Phil Longstaff plongstaff at code.gnucash.org
Mon Mar 15 12:10:27 EDT 2010


Author: plongstaff
Date: 2010-03-15 12:10:26 -0400 (Mon, 15 Mar 2010)
New Revision: 18911
Trac: http://svn.gnucash.org/trac/changeset/18911

Modified:
   gnucash/trunk/src/import-export/csv/gnc-csv-import.c
Log:
Partial fix for #611014 - CSV import crashes

Bug #611014 mentions a problem where after setting the columns, clicking OK and selecting a target account, the Date column is lost.  This is because of a difference in behaviour on windows and linux.  The code attaches to the "edited" signal of the renderer.  On linux, this signal is emitted when a new combo box item is selected.  On windows, the combo box needs to be selected and focus lost before the signal is emitted.  This is changed to the "changed" signal of the renderer which acts as expected on both platforms.


Modified: gnucash/trunk/src/import-export/csv/gnc-csv-import.c
===================================================================
--- gnucash/trunk/src/import-export/csv/gnc-csv-import.c	2010-03-15 14:49:39 UTC (rev 18910)
+++ gnucash/trunk/src/import-export/csv/gnc-csv-import.c	2010-03-15 16:10:26 UTC (rev 18911)
@@ -329,14 +329,22 @@
  * @param new_text The text the user selected
  * @param preview The display of the data being imported
  */
-static void column_type_edited(GtkCellRenderer* renderer, gchar* path,
-                               gchar* new_text, GncCsvPreview* preview)
+static void column_type_changed(GtkCellRenderer* renderer, gchar* path,
+                               GtkTreeIter* new_text_iter, GncCsvPreview* preview)
 {
     /* ncols is the number of columns in the data. */
     int i, ncols = preview->parse_data->column_types->len;
     /* store has the actual strings that appear in preview->ctreeview. */
     GtkTreeModel* store = gtk_tree_view_get_model(preview->ctreeview);
+    GtkTreeModel* model;
+    gint textColumn;
     GtkTreeIter iter;
+    gchar* new_text;
+
+    /* Get the new text */
+    g_object_get(renderer, "model", &model, "text-column", &textColumn, NULL);
+    gtk_tree_model_get(model, new_text_iter, textColumn, &new_text, -1);
+
     /* Get an iterator for the first (and only) row. */
     gtk_tree_model_get_iter_first(store, &iter);
 
@@ -344,7 +352,7 @@
     for (i = 0; i < ncols; i++)
     {
         /* We need all this stuff so that we can find out whether or not
-         * this was the column that was edited. */
+         * this was the column that was changed. */
         GtkCellRenderer* col_renderer; /* The renderer for this column. */
         /* The column in the treeview we are looking at */
         GtkTreeViewColumn* col = gtk_tree_view_get_column(preview->ctreeview, i);
@@ -354,7 +362,7 @@
         col_renderer = rend_list->data;
         g_list_free(rend_list);
 
-        /* If this is not the column that was edited ... */
+        /* If this is not the column that was changed ... */
         if (col_renderer != renderer)
         {
             /* The string that appears in the column */
@@ -373,7 +381,7 @@
             }
             g_free(contents);
         }
-        else /* If this is the column that was edited ... */
+        else /* If this is the column that was changed ... */
         {
             /* Set the text for this column to what the user selected. (See
              * comment above "Get the type string. ..." for why we set
@@ -963,8 +971,8 @@
          * types. */
         g_object_set(G_OBJECT(crenderer), "model", cstores[i], "text-column", 0,
                      "editable", TRUE, "has-entry", FALSE, NULL);
-        g_signal_connect(G_OBJECT(crenderer), "edited",
-                         G_CALLBACK(column_type_edited), (gpointer)preview);
+        g_signal_connect(G_OBJECT(crenderer), "changed",
+                         G_CALLBACK(column_type_changed), (gpointer)preview);
 
         /* Add a single column for the treeview. */
         col = gtk_tree_view_column_new_with_attributes("", renderer, "text", i, NULL);



More information about the gnucash-changes mailing list