From 9f75979fd2978d84d13398d0678293a495627c72 Mon Sep 17 00:00:00 2001 From: Sergio Villar Senin Date: Thu, 28 Feb 2008 12:38:25 +0000 Subject: [PATCH] * Fixes NB#81497, crash in the easysetup combo box pmo-trunk-r4246 --- .../easysetup/modest-easysetup-country-combo-box.c | 29 ++++++++------- .../easysetup/modest-easysetup-country-combo-box.h | 28 +++++++-------- .../easysetup/modest-easysetup-wizard-dialog.c | 38 +++++++++++++++----- 3 files changed, 57 insertions(+), 38 deletions(-) diff --git a/src/maemo/easysetup/modest-easysetup-country-combo-box.c b/src/maemo/easysetup/modest-easysetup-country-combo-box.c index b761ae9..9630810 100644 --- a/src/maemo/easysetup/modest-easysetup-country-combo-box.c +++ b/src/maemo/easysetup/modest-easysetup-country-combo-box.c @@ -53,15 +53,14 @@ G_DEFINE_TYPE (EasysetupCountryComboBox, easysetup_country_combo_box, GTK_TYPE_COMBO_BOX); -#define COUNTRY_COMBO_BOX_GET_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((o), EASYSETUP_TYPE_COUNTRY_COMBO_BOX, EasysetupCountryComboBoxPrivate)) - -typedef struct _EasysetupCountryComboBoxPrivate EasysetupCountryComboBoxPrivate; - -struct _EasysetupCountryComboBoxPrivate +typedef struct { GtkTreeModel *model; -}; +} ModestEasysetupCountryComboBoxPrivate; + +#define MODEST_EASYSETUP_COUNTRY_COMBO_BOX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ + MODEST_EASYSETUP_TYPE_COUNTRY_COMBO_BOX, \ + ModestEasysetupCountryComboBoxPrivate)) static void easysetup_country_combo_box_get_property (GObject *object, guint property_id, @@ -99,7 +98,7 @@ enum MODEL_COLS { static void easysetup_country_combo_box_finalize (GObject *object) { - EasysetupCountryComboBoxPrivate *priv = COUNTRY_COMBO_BOX_GET_PRIVATE (object); + ModestEasysetupCountryComboBoxPrivate *priv = MODEST_EASYSETUP_COUNTRY_COMBO_BOX_GET_PRIVATE (object); g_object_unref (G_OBJECT (priv->model)); G_OBJECT_CLASS (easysetup_country_combo_box_parent_class)->finalize (object); @@ -110,7 +109,7 @@ easysetup_country_combo_box_class_init (EasysetupCountryComboBoxClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (EasysetupCountryComboBoxPrivate)); + g_type_class_add_private (klass, sizeof (ModestEasysetupCountryComboBoxPrivate)); object_class->get_property = easysetup_country_combo_box_get_property; object_class->set_property = easysetup_country_combo_box_set_property; @@ -194,7 +193,7 @@ parse_mcc_mapping_line (const char* line, char** country) static void load_from_file (EasysetupCountryComboBox *self) { - EasysetupCountryComboBoxPrivate *priv = COUNTRY_COMBO_BOX_GET_PRIVATE (self); + ModestEasysetupCountryComboBoxPrivate *priv = MODEST_EASYSETUP_COUNTRY_COMBO_BOX_GET_PRIVATE (self); GtkListStore *liststore = GTK_LIST_STORE (priv->model); char line[MAX_LINE_LEN]; @@ -247,14 +246,14 @@ load_from_file (EasysetupCountryComboBox *self) static void easysetup_country_combo_box_init (EasysetupCountryComboBox *self) { - EasysetupCountryComboBoxPrivate *priv = COUNTRY_COMBO_BOX_GET_PRIVATE (self); + ModestEasysetupCountryComboBoxPrivate *priv = MODEST_EASYSETUP_COUNTRY_COMBO_BOX_GET_PRIVATE (self); priv->model = NULL; } void easysetup_country_combo_box_load_data(EasysetupCountryComboBox *self) { - EasysetupCountryComboBoxPrivate *priv = COUNTRY_COMBO_BOX_GET_PRIVATE (self); + ModestEasysetupCountryComboBoxPrivate *priv = MODEST_EASYSETUP_COUNTRY_COMBO_BOX_GET_PRIVATE (self); /* Create a tree model for the combo box, * with a string for the name, and an int for the MCC ID. @@ -286,7 +285,7 @@ easysetup_country_combo_box_load_data(EasysetupCountryComboBox *self) EasysetupCountryComboBox* easysetup_country_combo_box_new (void) { - return g_object_new (EASYSETUP_TYPE_COUNTRY_COMBO_BOX, NULL); + return g_object_new (MODEST_EASYSETUP_TYPE_COUNTRY_COMBO_BOX, NULL); } /** @@ -298,7 +297,7 @@ easysetup_country_combo_box_get_active_country_mcc (EasysetupCountryComboBox *se GtkTreeIter active; const gboolean found = gtk_combo_box_get_active_iter (GTK_COMBO_BOX (self), &active); if (found) { - EasysetupCountryComboBoxPrivate *priv = COUNTRY_COMBO_BOX_GET_PRIVATE (self); + ModestEasysetupCountryComboBoxPrivate *priv = MODEST_EASYSETUP_COUNTRY_COMBO_BOX_GET_PRIVATE (self); gint mcc = 0; gtk_tree_model_get (priv->model, &active, MODEL_COL_MCC, &mcc, -1); return mcc; @@ -314,7 +313,7 @@ easysetup_country_combo_box_get_active_country_mcc (EasysetupCountryComboBox *se gboolean easysetup_country_combo_box_set_active_country_mcc (EasysetupCountryComboBox *self, guint mcc) { - EasysetupCountryComboBoxPrivate *priv = COUNTRY_COMBO_BOX_GET_PRIVATE (self); + ModestEasysetupCountryComboBoxPrivate *priv = MODEST_EASYSETUP_COUNTRY_COMBO_BOX_GET_PRIVATE (self); GtkTreeIter iter; if (!gtk_tree_model_get_iter_first (priv->model, &iter)) diff --git a/src/maemo/easysetup/modest-easysetup-country-combo-box.h b/src/maemo/easysetup/modest-easysetup-country-combo-box.h index c89ecf1..a34eb5b 100644 --- a/src/maemo/easysetup/modest-easysetup-country-combo-box.h +++ b/src/maemo/easysetup/modest-easysetup-country-combo-box.h @@ -27,34 +27,34 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _EASYSETUP_COUNTRY_COMBO_BOX -#define _EASYSETUP_COUNTRY_COMBO_BOX +#ifndef _MODEST_EASYSETUP_COUNTRY_COMBO_BOX +#define _MODEST_EASYSETUP_COUNTRY_COMBO_BOX #include G_BEGIN_DECLS -#define EASYSETUP_TYPE_COUNTRY_COMBO_BOX easysetup_country_combo_box_get_type() +#define MODEST_EASYSETUP_TYPE_COUNTRY_COMBO_BOX easysetup_country_combo_box_get_type() -#define EASYSETUP_COUNTRY_COMBO_BOX(obj) \ +#define MODEST_EASYSETUP_COUNTRY_COMBO_BOX(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - EASYSETUP_TYPE_COUNTRY_COMBO_BOX, EasysetupCountryComboBox)) + MODEST_EASYSETUP_TYPE_COUNTRY_COMBO_BOX, EasysetupCountryComboBox)) -#define EASYSETUP_COUNTRY_COMBO_BOX_CLASS(klass) \ +#define MODEST_EASYSETUP_COUNTRY_COMBO_BOX_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - EASYSETUP_TYPE_COUNTRY_COMBO_BOX, EasysetupCountryComboBoxClass)) + MODEST_EASYSETUP_TYPE_COUNTRY_COMBO_BOX, EasysetupCountryComboBoxClass)) -#define EASYSETUP_IS_COUNTRY_COMBO_BOX(obj) \ +#define MODEST_EASYSETUP_IS_COUNTRY_COMBO_BOX(obj) \ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - EASYSETUP_TYPE_COUNTRY_COMBO_BOX)) + MODEST_EASYSETUP_TYPE_COUNTRY_COMBO_BOX)) -#define EASYSETUP_IS_COUNTRY_COMBO_BOX_CLASS(klass) \ +#define MODEST_EASYSETUP_IS_COUNTRY_COMBO_BOX_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - EASYSETUP_TYPE_COUNTRY_COMBO_BOX)) + MODEST_EASYSETUP_TYPE_COUNTRY_COMBO_BOX)) -#define EASYSETUP_COUNTRY_COMBO_BOX_GET_CLASS(obj) \ +#define MODEST_EASYSETUP_COUNTRY_COMBO_BOX_GET_CLASS(obj) \ (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - EASYSETUP_TYPE_COUNTRY_COMBO_BOX, EasysetupCountryComboBoxClass)) + MODEST_EASYSETUP_TYPE_COUNTRY_COMBO_BOX, EasysetupCountryComboBoxClass)) typedef struct { GtkComboBox parent; @@ -77,4 +77,4 @@ gboolean easysetup_country_combo_box_set_active_country_mcc (EasysetupCountryCom G_END_DECLS -#endif /* _EASYSETUP_COUNTRY_COMBO_BOX */ +#endif /* _MODEST_EASYSETUP_COUNTRY_COMBO_BOX */ diff --git a/src/maemo/easysetup/modest-easysetup-wizard-dialog.c b/src/maemo/easysetup/modest-easysetup-wizard-dialog.c index 223f00b..542dd01 100644 --- a/src/maemo/easysetup/modest-easysetup-wizard-dialog.c +++ b/src/maemo/easysetup/modest-easysetup-wizard-dialog.c @@ -407,7 +407,7 @@ on_combo_account_country (GtkComboBox *widget, gpointer user_data) /* Fill the providers combo, based on the selected country: */ if (priv->presets != NULL) { gint mcc = easysetup_country_combo_box_get_active_country_mcc ( - EASYSETUP_COUNTRY_COMBO_BOX (priv->combo_account_country)); + MODEST_EASYSETUP_COUNTRY_COMBO_BOX (priv->combo_account_country)); easysetup_provider_combo_box_fill ( EASYSETUP_PROVIDER_COMBO_BOX (priv->combo_account_serviceprovider), priv->presets, mcc); } @@ -1163,13 +1163,13 @@ presets_idle (gpointer userdata) priv->presets = idle_data->presets; - if (priv->combo_account_country) { + if (MODEST_EASYSETUP_IS_COUNTRY_COMBO_BOX (priv->combo_account_country)) { gint mcc = get_default_country_code(); /* Fill the combo in an idle call, as it takes a lot of time */ easysetup_country_combo_box_load_data( - EASYSETUP_COUNTRY_COMBO_BOX (priv->combo_account_country)); + MODEST_EASYSETUP_COUNTRY_COMBO_BOX (priv->combo_account_country)); easysetup_country_combo_box_set_active_country_mcc ( - EASYSETUP_COUNTRY_COMBO_BOX (priv->combo_account_country), mcc); + MODEST_EASYSETUP_COUNTRY_COMBO_BOX (priv->combo_account_country), mcc); easysetup_provider_combo_box_fill ( EASYSETUP_PROVIDER_COMBO_BOX (priv->combo_account_serviceprovider), priv->presets, mcc); @@ -1248,16 +1248,36 @@ modest_easysetup_wizard_dialog_init (ModestEasysetupWizardDialog *self) * so we can check for existing accounts, * and create new accounts: */ priv->account_manager = modest_runtime_get_account_mgr (); - g_assert (priv->account_manager); g_object_ref (priv->account_manager); - /* Create the common pages, - */ - priv->combo_account_country = NULL; + /* Initialize fields */ priv->page_welcome = create_page_welcome (self); priv->page_account_details = create_page_account_details (self); priv->page_user_details = create_page_user_details (self); - + priv->page_account_details = NULL; + priv->combo_account_country = NULL; + priv->combo_account_serviceprovider = NULL; + priv->entry_account_title = NULL; + priv->entry_user_name = NULL; + priv->entry_user_username = NULL; + priv->entry_user_password = NULL; + priv->entry_user_email = NULL; + priv->page_complete_easysetup = NULL; + priv->page_custom_incoming = NULL; + priv->combo_incoming_servertype = NULL; + priv->caption_incoming = NULL; + priv->entry_incomingserver = NULL; + priv->combo_incoming_security = NULL; + priv->checkbox_incoming_auth = NULL; + priv->page_custom_outgoing = NULL; + priv->entry_outgoingserver = NULL; + priv->combo_outgoing_security = NULL; + priv->combo_outgoing_auth = NULL; + priv->checkbox_outgoing_smtp_specific = NULL; + priv->button_outgoing_smtp_servers = NULL; + priv->page_complete_customsetup = NULL; + priv->specific_window = NULL; + /* Add the common pages: */ gtk_notebook_append_page (notebook, priv->page_welcome, gtk_label_new (_("mcen_ti_emailsetup_welcome"))); -- 1.7.9.5