Test program. Make it crash less often
authorJohn Darrington <john@darrington.wattle.id.au>
Sat, 9 Mar 2013 08:15:49 +0000 (09:15 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Sat, 9 Mar 2013 08:15:49 +0000 (09:15 +0100)
src/ui/gui/spreadsheet-test.c

index c0608886a4a61544645b97e7ac89f28cee4cff27..90a10375ec460dbfd04a76c2a5a5091a508d341e 100644 (file)
 #include "data/spreadsheet-reader.h"
 #include "data/casereader.h"
 #include "data/case.h"
+#include "libpspp/message.h"
 #include "gl/xalloc.h"
 
-#if 0
-#define N 10
-
-
-static GtkListStore *
-make_store ()
-  {
-    int i;
-    GtkTreeIter iter;
-    
-    GtkListStore * list_store  = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_STRING);
-
-    for (i = 0; i < N; ++i)
-      {
-       gtk_list_store_append (list_store, &iter);
-       gtk_list_store_set (list_store, &iter,
-                           0, N - i,
-                           1, "xxx", 
-                           -1);
-      }
-    return list_store;
-  }
-#endif
-
 
 struct xxx
 {
@@ -80,6 +57,10 @@ on_clicked (GtkButton *button, struct xxx *stuff)
   opts.asw = -1;
 
   reader = spreadsheet_make_reader (stuff->sp, &opts);
+
+  if (reader == NULL)
+    return;
+
   proto = casereader_get_proto (reader);
 
   nvals = caseproto_get_n_widths (proto);
@@ -109,6 +90,12 @@ on_clicked (GtkButton *button, struct xxx *stuff)
   casereader_destroy (reader);
 }
 
+static void 
+print_msg (const struct msg *m, void *aux UNUSED)
+{
+  fprintf (stderr, "%s\n", m->text);
+}
+
 
 int
 main (int argc, char *argv[] )
@@ -127,6 +114,8 @@ main (int argc, char *argv[] )
   if ( argc < 2)
     g_error ("Usage: prog file\n");
 
+  msg_set_handler (print_msg, 0);
+
   stuff.sp = NULL;
 
   if (stuff.sp == NULL)