From: John Darrington Date: Tue, 7 Aug 2007 00:56:59 +0000 (+0000) Subject: Fixed the two biggest sources of GtkCritical errors. X-Git-Tag: v0.6.0~325 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32884aab5da9ba8455d482dc1f52989ff7de4ee6;p=pspp-builds.git Fixed the two biggest sources of GtkCritical errors. --- diff --git a/src/ui/gui/ChangeLog b/src/ui/gui/ChangeLog index 6a368e00..3b4a450b 100644 --- a/src/ui/gui/ChangeLog +++ b/src/ui/gui/ChangeLog @@ -1,3 +1,16 @@ +2007-08-07 John Darrington + + * helper.c (execute_syntax): Set the active file data to NULL at the + end of the procedure. Thanks to Ben for suggesting this. + + * psppire-case-file.c: Added assertions to the remaining functions + on inaccessible objects. + + * psppire-data-store.c psppire-data-store.h: Disconnect or block + signals on dictionary and case_file, when make_reader has been called. + Reconnect or unblock them when a new datasheet has been set for the + data_store. + 2007-08-06 John Darrington * syntax-editor.glade: Changed some properties to be less annoying. diff --git a/src/ui/gui/helper.c b/src/ui/gui/helper.c index 274635d7..98bd4179 100644 --- a/src/ui/gui/helper.c +++ b/src/ui/gui/helper.c @@ -201,6 +201,8 @@ execute_syntax (struct getl_interface *sss) psppire_data_store_set_case_file (the_data_store, pcf); } + proc_set_active_file_data (the_dataset, NULL); + som_flush (); } diff --git a/src/ui/gui/psppire-case-file.c b/src/ui/gui/psppire-case-file.c index a44309ee..bb6f8b55 100644 --- a/src/ui/gui/psppire-case-file.c +++ b/src/ui/gui/psppire-case-file.c @@ -168,6 +168,7 @@ psppire_case_file_delete_cases (PsppireCaseFile *cf, casenumber n_cases, casenum { g_return_val_if_fail (cf, FALSE); g_return_val_if_fail (cf->datasheet, FALSE); + g_return_val_if_fail (cf->accessible, FALSE); g_return_val_if_fail (first + n_cases <= psppire_case_file_get_case_count (cf), FALSE); @@ -190,6 +191,7 @@ psppire_case_file_insert_case (PsppireCaseFile *cf, g_return_val_if_fail (cf, FALSE); g_return_val_if_fail (cf->datasheet, FALSE); + g_return_val_if_fail (cf->accessible, FALSE); case_clone (&tmp, cc); result = datasheet_insert_rows (cf->datasheet, posn, &tmp, 1); @@ -204,7 +206,7 @@ psppire_case_file_insert_case (PsppireCaseFile *cf, /* Append a case to the case file */ -gboolean +static gboolean psppire_case_file_append_case (PsppireCaseFile *cf, struct ccase *c) { @@ -214,6 +216,7 @@ psppire_case_file_append_case (PsppireCaseFile *cf, g_return_val_if_fail (cf, FALSE); g_return_val_if_fail (cf->datasheet, FALSE); + g_return_val_if_fail (cf->accessible, FALSE); posn = datasheet_get_row_cnt (cf->datasheet); diff --git a/src/ui/gui/psppire-data-store.c b/src/ui/gui/psppire-data-store.c index f79f4473..1e6568b7 100644 --- a/src/ui/gui/psppire-data-store.c +++ b/src/ui/gui/psppire-data-store.c @@ -178,6 +178,8 @@ psppire_data_store_init (PsppireDataStore *data_store) data_store->dict = 0; data_store->case_file = 0; data_store->width_of_m = 10; + + } const PangoFontDescription * @@ -384,36 +386,55 @@ psppire_data_store_new (PsppireDict *dict) void -psppire_data_store_set_case_file (PsppireDataStore *data_store, +psppire_data_store_set_case_file (PsppireDataStore *ds, PsppireCaseFile *cf) { - if ( data_store->case_file) + gint i; + if ( ds->case_file) { - g_object_unref (data_store->case_file); + g_object_unref (ds->case_file); } - data_store->case_file = cf; + ds->case_file = cf; - g_sheet_model_range_changed (G_SHEET_MODEL (data_store), + g_sheet_model_range_changed (G_SHEET_MODEL (ds), -1, -1, -1, -1); + for (i = 0 ; i < n_cf_signals ; ++i ) + { + if ( ds->cf_handler_id [i] > 0 ) + g_signal_handler_disconnect (ds->case_file, + ds->cf_handler_id[i]); + } + - g_signal_connect (data_store->case_file, "cases-deleted", - G_CALLBACK (delete_cases_callback), - data_store); + if ( ds->dict ) + for (i = 0 ; i < n_dict_signals; ++i ) + { + if ( ds->dict_handler_id [i] > 0) + { + g_signal_handler_unblock (ds->dict, + ds->dict_handler_id[i]); + } + } - g_signal_connect (data_store->case_file, "case-inserted", - G_CALLBACK (insert_case_callback), - data_store); + ds->cf_handler_id [CASES_DELETED] = + g_signal_connect (ds->case_file, "cases-deleted", + G_CALLBACK (delete_cases_callback), + ds); + ds->cf_handler_id [CASE_INSERTED] = + g_signal_connect (ds->case_file, "case-inserted", + G_CALLBACK (insert_case_callback), + ds); - g_signal_connect (data_store->case_file, "case-changed", - G_CALLBACK (changed_case_callback), - data_store); + ds->cf_handler_id [CASE_CHANGED] = + g_signal_connect (ds->case_file, "case-changed", + G_CALLBACK (changed_case_callback), + ds); } - /** * psppire_data_store_replace_set_dictionary: * @data_store: The variable store @@ -425,28 +446,59 @@ psppire_data_store_set_case_file (PsppireDataStore *data_store, void psppire_data_store_set_dictionary (PsppireDataStore *data_store, PsppireDict *dict) { + int i; + + /* Disconnect any existing handlers */ + if ( data_store->dict ) + for (i = 0 ; i < n_dict_signals; ++i ) + { + g_signal_handler_disconnect (data_store->dict, + data_store->dict_handler_id[i]); + } + data_store->dict = dict; - g_signal_connect (dict, "variable-inserted", - G_CALLBACK (insert_variable_callback), - data_store); + if ( dict != NULL) + { - g_signal_connect (dict, "variable-deleted", - G_CALLBACK (delete_variable_callback), - data_store); + data_store->dict_handler_id [VARIABLE_INSERTED] = + g_signal_connect (dict, "variable-inserted", + G_CALLBACK (insert_variable_callback), + data_store); + + data_store->dict_handler_id [VARIABLE_DELETED] = + g_signal_connect (dict, "variable-deleted", + G_CALLBACK (delete_variable_callback), + data_store); + + data_store->dict_handler_id [VARIABLE_CHANGED] = + g_signal_connect (dict, "variable-changed", + G_CALLBACK (variable_changed_callback), + data_store); + + data_store->dict_handler_id [SIZE_CHANGED] = + g_signal_connect (dict, "dict-size-changed", + G_CALLBACK (dict_size_change_callback), + data_store); + } - g_signal_connect (dict, "variable-changed", - G_CALLBACK (variable_changed_callback), - data_store); - g_signal_connect (dict, "dict-size-changed", - G_CALLBACK (dict_size_change_callback), - data_store); /* The entire model has changed */ g_sheet_model_range_changed (G_SHEET_MODEL (data_store), -1, -1, -1, -1); g_sheet_column_columns_changed (G_SHEET_COLUMN (data_store), 0, -1); + + + if ( data_store->dict ) + for (i = 0 ; i < n_dict_signals; ++i ) + { + if ( data_store->dict_handler_id [i] > 0) + { + g_signal_handler_block (data_store->dict, + data_store->dict_handler_id[i]); + } + } } static void @@ -673,8 +725,22 @@ psppire_data_store_clear (PsppireDataStore *data_store) struct casereader * psppire_data_store_get_reader (PsppireDataStore *ds) { + int i; struct casereader *reader ; + for (i = 0 ; i < n_cf_signals ; ++i ) + { + g_signal_handler_disconnect (ds->case_file, ds->cf_handler_id[i]); + ds->cf_handler_id[i] = 0 ; + } + + if ( ds->dict ) + for (i = 0 ; i < n_dict_signals; ++i ) + { + g_signal_handler_block (ds->dict, + ds->dict_handler_id[i]); + } + reader = psppire_case_file_make_reader (ds->case_file); return reader; @@ -835,7 +901,7 @@ geometry_pixel_to_row (const GSheetRow *geo, guint pixel, gpointer data) glong row = pixel / ROW_HEIGHT; if (row >= geometry_get_row_count (geo, data)) - row = geometry_get_row_count (geo, data) -1; + row = geometry_get_row_count (geo, data) - 1; return row; } diff --git a/src/ui/gui/psppire-data-store.h b/src/ui/gui/psppire-data-store.h index 8e29db33..ed4f0fd1 100644 --- a/src/ui/gui/psppire-data-store.h +++ b/src/ui/gui/psppire-data-store.h @@ -56,6 +56,26 @@ 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, + VARIABLE_DELETED, + SIZE_CHANGED, + n_dict_signals +}; + +void do_this_thing (PsppireDict *, struct dictionary *, void *); + + struct _PsppireDataStore { GObject parent; @@ -72,6 +92,9 @@ struct _PsppireDataStore /* Geometry */ gint margin_width; + + gint cf_handler_id [n_cf_signals]; + gint dict_handler_id [n_dict_signals]; }; struct _PsppireDataStoreClass