? Syntax1.sps
? agg.sps
? callbacks.patch
? cb.patch
? descriptives.sps
? diffs
? foo.sps
? libtool
? pspp.list
? rank-gui.patch
? rank.sps
? vg.5331
? x.patch
? src/ui/gui/.libs
? src/ui/gui/libpsppire.la
? src/ui/gui/src_ui_gui_libpsppire_la-glade-register.lo
Index: src/data/ChangeLog
===================================================================
RCS file: /sources/pspp/pspp/src/data/ChangeLog,v
retrieving revision 1.97
diff -b -w -U3 -r1.97 ChangeLog
--- src/data/ChangeLog	7 Jan 2007 04:04:00 -0000	1.97
+++ src/data/ChangeLog	9 Jan 2007 22:21:13 -0000
@@ -1,3 +1,8 @@
+Tue Jan  9 07:20:05 WST 2007 John Darrington <john@darrington.wattle.id.au>
+	* dictionary.c procedure.c: More changes to ensure that callbacks occur
+	whenever appropriate, but only when the dataset/dictionary is in a consistent 
+	state.
+
 Sun Jan  7 08:33:04 WST 2007 John Darrington <john@darrington.wattle.id.au>
 
 	* dictionary.c dictionary.h : Added callbacks for change of filter and 
Index: src/data/dictionary.c
===================================================================
RCS file: /sources/pspp/pspp/src/data/dictionary.c,v
retrieving revision 1.29
diff -b -w -U3 -r1.29 dictionary.c
--- src/data/dictionary.c	7 Jan 2007 04:04:00 -0000	1.29
+++ src/data/dictionary.c	9 Jan 2007 22:21:14 -0000
@@ -155,17 +155,17 @@
 {
   /* FIXME?  Should we really clear case_limit, label, documents?
      Others are necessarily cleared by deleting all the variables.*/
-  int i;
-
   assert (d != NULL);
 
-  for (i = 0; i < d->var_cnt; i++)
+  while (d->var_cnt > 0 )
     {
-      if (d->callbacks &&  d->callbacks->var_deleted )
-	d->callbacks->var_deleted (d, i, d->cb_data);
+      var_clear_vardict (d->var[d->var_cnt - 1]);
+      var_destroy (d->var[d->var_cnt -1]);
 
-      var_clear_vardict (d->var[i]);
-      var_destroy (d->var[i]);
+      d->var_cnt--;
+
+      if (d->callbacks &&  d->callbacks->var_deleted )
+	d->callbacks->var_deleted (d, d->var_cnt, d->cb_data);
     }
   free (d->var);
   d->var = NULL;
@@ -291,7 +291,7 @@
   hsh_force_insert (d->name_tab, v);
 
   if ( d->callbacks &&  d->callbacks->var_added )
-    d->callbacks->var_added (d, d->next_value_idx, d->cb_data);
+    d->callbacks->var_added (d, var_get_dict_index (v), d->cb_data);
 
   d->next_value_idx += var_get_value_cnt (v);
 
@@ -464,9 +464,6 @@
   remove_element (d->var, d->var_cnt, sizeof *d->var, dict_index);
   d->var_cnt--;
 
-  /* Update dict_index for each affected variable. */
-  reindex_vars (d, dict_index, d->var_cnt);
-
   /* Update name hash. */
   hsh_force_delete (d->name_tab, v);
 
@@ -477,6 +474,9 @@
 
   if (d->callbacks &&  d->callbacks->var_deleted )
     d->callbacks->var_deleted (d, dict_index, d->cb_data);
+
+  /* Update dict_index for each affected variable. */
+  reindex_vars (d, dict_index, d->var_cnt);
 }
 
 /* Deletes the COUNT variables listed in VARS from D.  This is
Index: src/data/procedure.c
===================================================================
RCS file: /sources/pspp/pspp/src/data/procedure.c,v
retrieving revision 1.23
diff -b -w -U3 -r1.23 procedure.c
--- src/data/procedure.c	7 Jan 2007 04:04:00 -0000	1.23
+++ src/data/procedure.c	9 Jan 2007 22:21:14 -0000
@@ -233,8 +233,6 @@
 
   if ( proc_close (ds) && ok )
     {
-      if ( ds->replace_source )
-	ds->replace_source (ds->proc_source);
 
       return true;
     }
@@ -347,7 +345,7 @@
         break;
     }
   ds->ok = free_case_source (ds->proc_source) && ds->ok;
-  ds->proc_source = NULL;
+  proc_set_source (ds, NULL);
 
   case_destroy (&ds->sink_case);
   case_destroy (&ds->trns_case);
@@ -492,7 +490,7 @@
 
   /* Old data sink becomes new data source. */
   if (ds->proc_sink->class->make_source != NULL)
-    ds->proc_source = ds->proc_sink->class->make_source (ds->proc_sink);
+    proc_set_source (ds, ds->proc_sink->class->make_source (ds->proc_sink) );
   free_case_sink (ds->proc_sink);
   ds->proc_sink = NULL;
 
@@ -727,10 +725,7 @@
   ds->n_lag = 0;
 
   free_case_source (ds->proc_source);
-  ds->proc_source = NULL;
-  if ( ds->replace_source )
-    ds->replace_source (ds->proc_source);
-
+  proc_set_source (ds, NULL);
 
   proc_cancel_all_transformations (ds);
 }
@@ -902,8 +897,10 @@
 void
 proc_set_source (struct dataset *ds, struct case_source *source)
 {
-  assert (ds->proc_source == NULL);
   ds->proc_source = source;
+
+  if ( ds->replace_source )
+    ds->replace_source (ds->proc_source);
 }
 
 /* Returns true if a source for the next procedure has been
@@ -931,7 +928,7 @@
   assert (!proc_in_temporary_transformations (ds));
 
   casefile = storage_source_decapsulate (ds->proc_source);
-  ds->proc_source = NULL;
+  proc_set_source (ds, NULL);
 
   return casefile;
 }
Index: src/language/stats/rank.q
===================================================================
RCS file: /sources/pspp/pspp/src/language/stats/rank.q,v
retrieving revision 1.25
diff -b -w -U3 -r1.25 rank.q
--- src/language/stats/rank.q	23 Dec 2006 06:11:33 -0000	1.25
+++ src/language/stats/rank.q	9 Jan 2007 22:21:15 -0000
@@ -1,7 +1,5 @@
 /* PSPP - RANK. -*-c-*-
-
-Copyright (C) 2005, 2006 Free Software Foundation, Inc.
-        Ben Pfaff <blp@gnu.org>.
+Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License as
@@ -742,9 +740,7 @@
   n_group_vars = 0;
   
   for (i = 0 ; i <  n_rank_specs ; ++i )
-    {
       free (rank_specs[i].destvars);
-    }
       
   free (rank_specs);
   rank_specs = NULL;
@@ -919,6 +915,7 @@
 
   rank_cleanup();
 
+
   return (result ? CMD_SUCCESS : CMD_CASCADING_FAILURE);
 }
 
Index: src/ui/gui/ChangeLog
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/ChangeLog,v
retrieving revision 1.35
diff -b -w -U3 -r1.35 ChangeLog
--- src/ui/gui/ChangeLog	7 Jan 2007 04:04:00 -0000	1.35
+++ src/ui/gui/ChangeLog	9 Jan 2007 22:21:15 -0000
@@ -1,3 +1,14 @@
+Wed Jan 10 07:20:39 WST 2007 John Darrington <john@darrington.wattle.id.au>
+
+	* psppire-case-file.c : Make sure there is always a valid flexifile
+
+	* psppire-data-store.c : assertions.
+
+	* psppire.c: Ignore replace source callbacks if the new source is 
+	  not of storiage_source_class
+
+	* syntax-editor.c: Close/Abort source after parsing is complete.
+
 Sun Jan  7 08:38:29 WST 2007 John Darrington <john@darrington.wattle.id.au>
 
 	* psppire-dict.c: Add FILTER_CHANGED and SPLIT_CHANGED signals 
Index: src/ui/gui/psppire-case-file.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/psppire-case-file.c,v
retrieving revision 1.14
diff -b -w -U3 -r1.14 psppire-case-file.c
--- src/ui/gui/psppire-case-file.c	1 Jan 2007 01:44:33 -0000	1.14
+++ src/ui/gui/psppire-case-file.c	9 Jan 2007 22:21:15 -0000
@@ -157,6 +157,8 @@
 {
   PsppireCaseFile *cf = g_object_new (G_TYPE_PSPPIRE_CASE_FILE, NULL);
 
+  cf->flexifile = flexifile_create (0);
+
   return cf;
 }
 
Index: src/ui/gui/psppire-data-store.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/psppire-data-store.c,v
retrieving revision 1.31
diff -b -w -U3 -r1.31 psppire-data-store.c
--- src/ui/gui/psppire-data-store.c	1 Jan 2007 01:44:33 -0000	1.31
+++ src/ui/gui/psppire-data-store.c	9 Jan 2007 22:21:15 -0000
@@ -317,8 +317,10 @@
 
   if ( var_num > 0 )
     {
-      struct variable *variable;
-      variable = psppire_dict_get_variable (store->dict, var_num);
+      struct variable *variable =
+	psppire_dict_get_variable (store->dict, var_num);
+
+      g_assert (variable != NULL);
 
       posn = var_get_case_index (variable);
     }
@@ -367,7 +369,6 @@
 
   psppire_data_store_set_dictionary (retval, dict);
 
-
   return retval;
 }
 
@@ -394,6 +395,8 @@
 
   data_store->case_file = psppire_case_file_new ();
 
+
+
   g_signal_connect (data_store->case_file, "cases-deleted",
 		   G_CALLBACK (delete_cases_callback),
 		   data_store);
@@ -496,8 +499,12 @@
 
   pv = psppire_dict_get_variable (store->dict, column);
 
+  g_assert (pv);
+
   idx = var_get_case_index (pv);
 
+  g_assert (idx >= 0);
+
   v = psppire_case_file_get_value (store->case_file, row, idx);
 
   g_return_val_if_fail (v, NULL);
Index: src/ui/gui/psppire.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/psppire.c,v
retrieving revision 1.33
diff -b -w -U3 -r1.33 psppire.c
--- src/ui/gui/psppire.c	1 Jan 2007 01:44:33 -0000	1.33
+++ src/ui/gui/psppire.c	9 Jan 2007 22:21:15 -0000
@@ -29,6 +29,7 @@
 #include <data/file-handle-def.h>
 #include <data/format.h>
 #include <data/storage-stream.h>
+#include <data/case-source.h>
 #include <data/settings.h>
 #include <data/file-name.h>
 #include <data/procedure.h>
@@ -78,10 +79,15 @@
     psppire_case_file_replace_flexifile (the_data_store->case_file,
 					 (struct flexifile *) flexifile_create (0));
   else
+    {
+      if ( ! case_source_is_class (s, &storage_source_class))
+	return ;
+
     psppire_case_file_replace_flexifile (the_data_store->case_file,
 					 (struct flexifile *)
 					 storage_source_get_casefile (s));
 }
+}
 
 
 int
Index: src/ui/gui/syntax-editor-source.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/syntax-editor-source.c,v
retrieving revision 1.3
diff -b -w -U3 -r1.3 syntax-editor-source.c
Index: src/ui/gui/syntax-editor.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/syntax-editor.c,v
retrieving revision 1.12
diff -b -w -U3 -r1.12 syntax-editor.c
--- src/ui/gui/syntax-editor.c	1 Jan 2007 01:44:33 -0000	1.12
+++ src/ui/gui/syntax-editor.c	9 Jan 2007 22:21:15 -0000
@@ -228,6 +228,8 @@
       if (result == CMD_EOF || result == CMD_FINISH)
 	break;
     }
+
+  getl_abort_noninteractive (the_source_stream);
 }
 
 /* Parse and execute all the text in the buffer */
