From: John Darrington Date: Tue, 2 Dec 2008 01:58:52 +0000 (+0900) Subject: Destroy datasheet, but not if we've made a reader of it X-Git-Tag: v0.7.1~83 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c94183521bb50d92ae05153f6013af0bc347299e;p=pspp-builds.git Destroy datasheet, but not if we've made a reader of it --- diff --git a/src/ui/gui/psppire-data-store.c b/src/ui/gui/psppire-data-store.c index 36d1af78..2907f5fc 100644 --- a/src/ui/gui/psppire-data-store.c +++ b/src/ui/gui/psppire-data-store.c @@ -43,6 +43,15 @@ #include "xalloc.h" #include "xmalloca.h" + +enum cf_signal_handler { + CASES_DELETED, + CASE_INSERTED, + CASE_CHANGED, + n_cf_signals +}; + + static void psppire_data_store_init (PsppireDataStore *data_store); static void psppire_data_store_class_init (PsppireDataStoreClass *class); static void psppire_data_store_sheet_model_init (GSheetModelIface *iface); @@ -405,6 +414,9 @@ psppire_data_store_set_reader (PsppireDataStore *ds, { gint i; + if ( ds->datasheet) + datasheet_destroy (ds->datasheet); + ds->datasheet = datasheet_create (reader); g_sheet_model_range_changed (G_SHEET_MODEL (ds), @@ -750,7 +762,12 @@ psppire_data_store_get_reader (PsppireDataStore *ds) ds->dict_handler_id[i]); } - return datasheet_make_reader (ds->datasheet); + reader = datasheet_make_reader (ds->datasheet); + + /* We must not reference this again */ + ds->datasheet = NULL; + + return reader; } @@ -907,6 +924,7 @@ psppire_data_store_insert_case (PsppireDataStore *ds, case_clone (&tmp, cc); result = datasheet_insert_rows (ds->datasheet, posn, &tmp, 1); + g_debug ("Result %d. Inserted case at posn %ld", result, posn); if ( result ) g_signal_emit (ds, signals [CASE_INSERTED], 0, posn); else diff --git a/src/ui/gui/psppire-data-store.h b/src/ui/gui/psppire-data-store.h index 0e988633..44b11725 100644 --- a/src/ui/gui/psppire-data-store.h +++ b/src/ui/gui/psppire-data-store.h @@ -53,14 +53,6 @@ typedef struct _PsppireDataStoreClass PsppireDataStoreClass; struct dictionary; -enum cf_signal_handler { - CASES_DELETED, - CASE_INSERTED, - CASE_CHANGED, - n_cf_signals -}; - - enum dict_signal_handler { VARIABLE_INSERTED, VARIABLE_CHANGED, @@ -84,7 +76,7 @@ struct _PsppireDataStore gboolean show_labels; - gint cf_handler_id [n_cf_signals]; + // gint cf_handler_id [n_cf_signals]; gint dict_handler_id [n_dict_signals]; };