Reference count struct dictionary.
[pspp] / src / ui / gui / psppire-import-assistant.c
index da72d507132f300647eac659e359f6f9460d9fb6..e376bacc7e667cf3ae9076d071c193fa940936ea 100644 (file)
@@ -127,6 +127,8 @@ psppire_import_assistant_finalize (GObject *object)
 
   ds_destroy (&ia->quotes);
 
+  dict_unref (ia->dict);
+
   g_object_unref (ia->builder);
 
   ia->response = -1;
@@ -1274,7 +1276,7 @@ prepare_formats_page (PsppireImportAssistant *ia)
 
       struct casereader *reader = spreadsheet_make_reader (ia->spreadsheet, &opts);
 
-      PsppireDict *dict = psppire_dict_new_from_dict (dict_clone (ia->spreadsheet->dict));
+      PsppireDict *dict = psppire_dict_new_from_dict (ia->spreadsheet->dict);
       PsppireDataStore *store = psppire_data_store_new (dict);
       psppire_data_store_set_reader (store, reader);
       g_object_set (ia->data_sheet, "data-model", store, NULL);
@@ -1546,8 +1548,8 @@ apply_dict (const struct dictionary *dict, struct string *s)
 
 
 
-static char *
-sheet_spec_gen_syntax (PsppireImportAssistant *ia)
+static void
+sheet_spec_gen_syntax (PsppireImportAssistant *ia, struct string *s)
 {
   GtkBuilder *builder = ia->builder;
   GtkWidget *range_entry = get_widget_assert (builder, "cell-range-entry");
@@ -1557,14 +1559,13 @@ sheet_spec_gen_syntax (PsppireImportAssistant *ia)
   int sheet_index = 1 + gtk_combo_box_get_active (GTK_COMBO_BOX (sheet_entry));
   gboolean read_names = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rnc));
 
-  struct string s = DS_EMPTY_INITIALIZER;
 
   char *filename;
   if (ia->spreadsheet)
     filename = ia->spreadsheet->file_name;
   else
     g_object_get (ia->text_file, "file-name", &filename, NULL);
-  syntax_gen_pspp (&s,
+  syntax_gen_pspp (s,
                   "GET DATA"
                   "\n  /TYPE=%ss"
                   "\n  /FILE=%sq"
@@ -1577,20 +1578,17 @@ sheet_spec_gen_syntax (PsppireImportAssistant *ia)
 
   if (range && 0 != strcmp ("", range))
     {
-      syntax_gen_pspp (&s,
+      syntax_gen_pspp (s,
                       "\n  /CELLRANGE=RANGE %sq", range);
     }
   else
     {
-      syntax_gen_pspp (&s,
+      syntax_gen_pspp (s,
                       "\n  /CELLRANGE=FULL");
     }
 
 
-  syntax_gen_pspp (&s, ".");
-
-
-  return ds_cstr (&s);
+  syntax_gen_pspp (s, ".\n");
 }
 
 
@@ -1632,7 +1630,7 @@ psppire_import_assistant_generate_syntax (PsppireImportAssistant *ia)
     }
   else
     {
-      return sheet_spec_gen_syntax (ia);
+      sheet_spec_gen_syntax (ia, &s);
     }
 
   return ds_cstr (&s);