From 704b78d23bf8d707707411608a3453250f2637a1 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 6 Nov 2012 16:20:46 +0100 Subject: Replace deprecated GLib symbols (as of GLib 2.34.x) --- calendar/alarm-notify/config-data.c | 26 +++----- calendar/alarm-notify/config-data.h | 2 + calendar/alarm-notify/notify-main.c | 2 + calendar/gui/calendar-config.c | 6 +- calendar/gui/e-cal-model.c | 18 +++--- calendar/gui/e-meeting-store.c | 30 ++++----- calendar/gui/gnome-cal.c | 24 +++---- composer/e-composer-header-table.c | 87 +++++++++----------------- em-format/e-mail-parser.c | 13 ++-- libemail-engine/e-mail-session.c | 16 ++--- libemail-engine/mail-folder-cache.c | 90 +++++++++++++-------------- libemail-utils/mail-mt.c | 38 +++++------ mail/e-mail-autoconfig.c | 6 +- mail/importers/elm-importer.c | 14 ++--- mail/importers/evolution-mbox-importer.c | 14 ++--- mail/importers/pine-importer.c | 14 ++--- mail/mail-send-recv.c | 14 ++--- mail/message-list.c | 20 +++--- mail/message-list.h | 2 +- modules/book-config-ldap/e-source-ldap.c | 26 ++++---- modules/cal-config-local/e-source-local.c | 14 ++--- modules/cal-config-weather/e-source-weather.c | 16 ++--- modules/spamassassin/evolution-spamassassin.c | 22 +++---- plugins/bbdb/bbdb.c | 5 +- plugins/bbdb/gaimbuddies.c | 5 +- plugins/dbx-import/dbx-importer.c | 14 ++--- plugins/external-editor/external-editor.c | 47 ++++++++------ plugins/mail-to-task/mail-to-task.c | 38 +++++------ plugins/pst-import/pst-importer.c | 14 ++--- plugins/publish-calendar/publish-calendar.c | 16 +++-- shell/e-convert-local-mail.c | 4 +- shell/e-shell.c | 25 ++------ smime/lib/e-cert-trust.c | 12 ++-- widgets/misc/e-attachment-bar.c | 2 +- widgets/misc/e-attachment-paned.c | 2 +- widgets/misc/e-attachment-tree-view.c | 2 +- widgets/misc/e-attachment.c | 2 +- widgets/misc/e-picture-gallery.c | 2 +- 38 files changed, 345 insertions(+), 359 deletions(-) diff --git a/calendar/alarm-notify/config-data.c b/calendar/alarm-notify/config-data.c index a2f9a2d448..b9f9b7a07d 100644 --- a/calendar/alarm-notify/config-data.c +++ b/calendar/alarm-notify/config-data.c @@ -31,7 +31,6 @@ /* Whether we have initied ourselves by reading * the data from the configuration engine. */ -static gboolean inited = FALSE; static GSettings *calendar_settings = NULL; /* Copied from ../calendar-config.c; returns whether the locale has 'am' and @@ -47,27 +46,22 @@ locale_supports_12_hour_format (void) return s[0] != '\0'; } -static void -do_cleanup (void) +void +config_data_cleanup (void) { - g_object_unref (calendar_settings); - calendar_settings = FALSE; - - inited = FALSE; + if (calendar_settings) + g_object_unref (calendar_settings); + calendar_settings = NULL; } /* Ensures that the configuration values have been read */ static void ensure_inited (void) { - if (inited) + if (calendar_settings) return; - inited = TRUE; - calendar_settings = g_settings_new ("org.gnome.evolution.calendar"); - - g_atexit ((GVoidFunc) do_cleanup); } icaltimezone * @@ -287,7 +281,7 @@ config_data_is_blessed_program (const gchar *program) } static gboolean can_debug = FALSE; -static GStaticRecMutex rec_mutex = G_STATIC_REC_MUTEX_INIT; +static GRecMutex rec_mutex; void config_data_init_debugging (void) @@ -301,12 +295,12 @@ config_data_init_debugging (void) gboolean config_data_start_debugging (void) { - g_static_rec_mutex_lock (&rec_mutex); + g_rec_mutex_lock (&rec_mutex); if (can_debug) return TRUE; - g_static_rec_mutex_unlock (&rec_mutex); + g_rec_mutex_unlock (&rec_mutex); return FALSE; } @@ -314,5 +308,5 @@ config_data_start_debugging (void) void config_data_stop_debugging (void) { - g_static_rec_mutex_unlock (&rec_mutex); + g_rec_mutex_unlock (&rec_mutex); } diff --git a/calendar/alarm-notify/config-data.h b/calendar/alarm-notify/config-data.h index c97c0f7415..d30781c693 100644 --- a/calendar/alarm-notify/config-data.h +++ b/calendar/alarm-notify/config-data.h @@ -29,6 +29,8 @@ #include #include +void config_data_cleanup (void); + icaltimezone * config_data_get_timezone (void); gboolean config_data_get_24_hour_format (void); gboolean config_data_get_notify_with_tray diff --git a/calendar/alarm-notify/notify-main.c b/calendar/alarm-notify/notify-main.c index c112331a3d..3643ae65e7 100644 --- a/calendar/alarm-notify/notify-main.c +++ b/calendar/alarm-notify/notify-main.c @@ -31,6 +31,7 @@ #include #include "alarm-notify.h" +#include "config-data.h" #ifdef G_OS_WIN32 #include @@ -117,6 +118,7 @@ main (gint argc, G_APPLICATION (alarm_notify_service), argc, argv); g_object_unref (alarm_notify_service); + config_data_cleanup (); return exit_status; } diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c index 50b370fd0f..b7822da165 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -55,7 +55,11 @@ calendar_config_init (void) return; config = g_settings_new ("org.gnome.evolution.calendar"); - g_atexit ((GVoidFunc) do_cleanup); + + /* will be freed together with EShell */ + g_object_set_data_full (G_OBJECT (e_shell_get_default ()), + "calendar-config-config-cleanup", (gpointer) "1", + (GDestroyNotify) do_cleanup); } void diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c index 8de4244902..3020a70300 100644 --- a/calendar/gui/e-cal-model.c +++ b/calendar/gui/e-cal-model.c @@ -123,7 +123,7 @@ struct _ECalModelPrivate { GHashTable *notify_modified; GHashTable *notify_removed; - GMutex *notify_lock; + GMutex notify_lock; GCancellable *loading_clients; }; @@ -484,7 +484,7 @@ cal_model_finalize (GObject *object) } g_ptr_array_free (priv->objects, FALSE); - g_mutex_free (priv->notify_lock); + g_mutex_clear (&priv->notify_lock); g_hash_table_destroy (priv->notify_added); g_hash_table_destroy (priv->notify_modified); @@ -767,7 +767,7 @@ e_cal_model_init (ECalModel *model) model->priv->notify_added = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, NULL); model->priv->notify_modified = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, NULL); model->priv->notify_removed = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, NULL); - model->priv->notify_lock = g_mutex_new (); + g_mutex_init (&model->priv->notify_lock); model->priv->loading_clients = g_cancellable_new (); } @@ -2652,7 +2652,7 @@ process_event (ECalClientView *view, g_return_if_fail (save_hash != NULL); - g_mutex_lock (model->priv->notify_lock); + g_mutex_lock (&model->priv->notify_lock); if (*in) { GSList *save_list = g_hash_table_lookup (save_hash, view); @@ -2667,7 +2667,7 @@ process_event (ECalClientView *view, *in = TRUE; } - g_mutex_unlock (model->priv->notify_lock); + g_mutex_unlock (&model->priv->notify_lock); if (skip) return; @@ -2675,7 +2675,7 @@ process_event (ECalClientView *view, /* do it */ process_fn (view, objects, model); - g_mutex_lock (model->priv->notify_lock); + g_mutex_lock (&model->priv->notify_lock); while (g_hash_table_size (save_hash)) { gpointer key = NULL, value = NULL; GHashTableIter iter; @@ -2692,7 +2692,7 @@ process_event (ECalClientView *view, g_hash_table_remove (save_hash, view); - g_mutex_unlock (model->priv->notify_lock); + g_mutex_unlock (&model->priv->notify_lock); /* do it */ process_fn (view, save_list, model); @@ -2705,11 +2705,11 @@ process_event (ECalClientView *view, g_slist_free (save_list); g_object_unref (view); - g_mutex_lock (model->priv->notify_lock); + g_mutex_lock (&model->priv->notify_lock); } *in = FALSE; - g_mutex_unlock (model->priv->notify_lock); + g_mutex_unlock (&model->priv->notify_lock); } static void diff --git a/calendar/gui/e-meeting-store.c b/calendar/gui/e-meeting-store.c index 0aaf8fed80..3449d5e0cb 100644 --- a/calendar/gui/e-meeting-store.c +++ b/calendar/gui/e-meeting-store.c @@ -64,7 +64,7 @@ struct _EMeetingStorePrivate { GPtrArray *refresh_queue; GHashTable *refresh_data; - GMutex *mutex; + GMutex mutex; guint refresh_idle_id; guint num_threads; @@ -617,11 +617,11 @@ refresh_queue_remove (EMeetingStore *store, } if (qdata) { - g_mutex_lock (priv->mutex); + g_mutex_lock (&priv->mutex); g_hash_table_remove ( priv->refresh_data, itip_strip_mailto ( e_meeting_attendee_get_address (attendee))); - g_mutex_unlock (priv->mutex); + g_mutex_unlock (&priv->mutex); g_ptr_array_free (qdata->call_backs, TRUE); g_ptr_array_free (qdata->data, TRUE); g_free (qdata); @@ -759,7 +759,7 @@ meeting_store_finalize (GObject *object) g_free (priv->fb_uri); - g_mutex_free (priv->mutex); + g_mutex_clear (&priv->mutex); /* Chain up to parent's finalize() method. */ G_OBJECT_CLASS (e_meeting_store_parent_class)->finalize (object); @@ -852,7 +852,7 @@ e_meeting_store_init (EMeetingStore *store) store->priv->refresh_data = g_hash_table_new_full ( g_str_hash, g_str_equal, g_free, NULL); - store->priv->mutex = g_mutex_new (); + g_mutex_init (&store->priv->mutex); store->priv->num_queries = 0; @@ -1331,9 +1331,9 @@ process_callbacks (EMeetingStoreQueueData *qdata) g_idle_add ((GSourceFunc) call_back, data); } - g_mutex_lock (store->priv->mutex); + g_mutex_lock (&store->priv->mutex); store->priv->num_threads--; - g_mutex_unlock (store->priv->mutex); + g_mutex_unlock (&store->priv->mutex); refresh_queue_remove (qdata->store, qdata->attendee); g_object_unref (store); @@ -1710,11 +1710,11 @@ refresh_busy_periods (gpointer data) } - g_mutex_lock (store->priv->mutex); + g_mutex_lock (&store->priv->mutex); store->priv->num_threads++; - g_mutex_unlock (store->priv->mutex); + g_mutex_unlock (&store->priv->mutex); - thread = g_thread_create ((GThreadFunc) freebusy_async, fbd, FALSE, &error); + thread = g_thread_try_new (NULL, (GThreadFunc) freebusy_async, fbd, &error); if (!thread) { /* do clean up stuff here */ g_slist_foreach (fbd->users, (GFunc) g_free, NULL); @@ -1722,13 +1722,15 @@ refresh_busy_periods (gpointer data) g_free (fbd->email); priv->refresh_idle_id = 0; - g_mutex_lock (store->priv->mutex); + g_mutex_lock (&store->priv->mutex); store->priv->num_threads--; - g_mutex_unlock (store->priv->mutex); + g_mutex_unlock (&store->priv->mutex); return FALSE; } + g_thread_unref (thread); + return TRUE; } @@ -1763,7 +1765,7 @@ refresh_queue_add (EMeetingStore *store, return; } - g_mutex_lock (priv->mutex); + g_mutex_lock (&priv->mutex); qdata = g_hash_table_lookup ( priv->refresh_data, itip_strip_mailto ( e_meeting_attendee_get_address (attendee))); @@ -1795,7 +1797,7 @@ refresh_queue_add (EMeetingStore *store, g_ptr_array_add (qdata->call_backs, call_back); g_ptr_array_add (qdata->data, data); } - g_mutex_unlock (priv->mutex); + g_mutex_unlock (&priv->mutex); g_object_ref (attendee); g_ptr_array_add (priv->refresh_queue, attendee); diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 4a37108fb0..b98857e717 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -89,7 +89,7 @@ struct _GnomeCalendarPrivate { GtkWidget *task_table; /* ETaskTable, but can be NULL */ /* Calendar query for the date navigator */ - GMutex *dn_query_lock; + GMutex dn_query_lock; GList *dn_queries; /* list of CalQueries */ gchar *sexp; gchar *todo_sexp; @@ -128,7 +128,7 @@ struct _GnomeCalendarPrivate { /* Used in update_todo_view, to prevent interleaving when * called in separate thread. */ - GMutex *todo_update_lock; + GMutex todo_update_lock; GCancellable *cancellable; }; @@ -1118,7 +1118,7 @@ free_dn_queries (GnomeCalendar *gcal) priv = gcal->priv; - g_mutex_lock (priv->dn_query_lock); + g_mutex_lock (&priv->dn_query_lock); for (l = priv->dn_queries; l != NULL; l = l->next) { if (!l->data) @@ -1131,7 +1131,7 @@ free_dn_queries (GnomeCalendar *gcal) g_list_free (priv->dn_queries); priv->dn_queries = NULL; - g_mutex_unlock (priv->dn_query_lock); + g_mutex_unlock (&priv->dn_query_lock); } static void @@ -1200,7 +1200,7 @@ update_query_async (struct _date_query_msg *msg) new_view, "complete", G_CALLBACK (dn_client_view_complete_cb), gcal); - g_mutex_lock (priv->dn_query_lock); + g_mutex_lock (&priv->dn_query_lock); priv->dn_queries = g_list_append (priv->dn_queries, new_view); e_cal_client_view_start (new_view, &error); if (error != NULL) { @@ -1209,7 +1209,7 @@ update_query_async (struct _date_query_msg *msg) G_STRFUNC, error->message); g_clear_error (&error); } - g_mutex_unlock (priv->dn_query_lock); + g_mutex_unlock (&priv->dn_query_lock); } g_list_foreach (list, (GFunc) g_object_unref, NULL); @@ -1315,7 +1315,7 @@ update_todo_view_async (struct _mupdate_todo_msg *msg) g_return_if_fail (priv->task_table != NULL); - g_mutex_lock (priv->todo_update_lock); + g_mutex_lock (&priv->todo_update_lock); /* Set the query on the task pad */ if (priv->todo_sexp) { @@ -1337,7 +1337,7 @@ update_todo_view_async (struct _mupdate_todo_msg *msg) update_memo_view (msg->gcal); - g_mutex_unlock (priv->todo_update_lock); + g_mutex_unlock (&priv->todo_update_lock); } static gboolean @@ -1494,8 +1494,8 @@ gnome_calendar_init (GnomeCalendar *gcal) { gcal->priv = GNOME_CALENDAR_GET_PRIVATE (gcal); - gcal->priv->todo_update_lock = g_mutex_new (); - gcal->priv->dn_query_lock = g_mutex_new (); + g_mutex_init (&gcal->priv->todo_update_lock); + g_mutex_init (&gcal->priv->dn_query_lock); gcal->priv->current_view_type = GNOME_CAL_WORK_WEEK_VIEW; gcal->priv->range_selected = FALSE; @@ -1578,8 +1578,8 @@ gnome_calendar_finalize (GObject *object) priv = GNOME_CALENDAR_GET_PRIVATE (object); - g_mutex_free (priv->todo_update_lock); - g_mutex_free (priv->dn_query_lock); + g_mutex_clear (&priv->todo_update_lock); + g_mutex_clear (&priv->dn_query_lock); /* Chain up to parent's finalize() method. */ G_OBJECT_CLASS (gnome_calendar_parent_class)->finalize (object); diff --git a/composer/e-composer-header-table.c b/composer/e-composer-header-table.c index 1290a6784f..72c8dacaa8 100644 --- a/composer/e-composer-header-table.c +++ b/composer/e-composer-header-table.c @@ -86,37 +86,33 @@ static void g_value_set_destinations (GValue *value, EDestination **destinations) { - GValueArray *value_array; - GValue element = G_VALUE_INIT; + GPtrArray *array; gint ii; - g_value_init (&element, E_TYPE_DESTINATION); - /* Preallocate some reasonable number. */ - value_array = g_value_array_new (64); + array = g_ptr_array_new_full (64, g_object_unref); for (ii = 0; destinations[ii] != NULL; ii++) { - g_value_set_object (&element, destinations[ii]); - g_value_array_append (value_array, &element); + g_ptr_array_add (array, e_destination_copy (destinations[ii])); } - g_value_take_boxed (value, value_array); + g_value_take_boxed (value, array); } static EDestination ** g_value_dup_destinations (const GValue *value) { EDestination **destinations; - GValueArray *value_array; - GValue *element; - gint ii; + const EDestination *dest; + GPtrArray *array; + guint ii; - value_array = g_value_get_boxed (value); - destinations = g_new0 (EDestination *, value_array->n_values + 1); + array = g_value_get_boxed (value); + destinations = g_new0 (EDestination *, array->len + 1); - for (ii = 0; ii < value_array->n_values; ii++) { - element = g_value_array_get_nth (value_array, ii); - destinations[ii] = g_value_dup_object (element); + for (ii = 0; ii < array->len; ii++) { + dest = g_ptr_array_index (array, ii); + destinations[ii] = e_destination_copy (dest); } return destinations; @@ -126,34 +122,30 @@ static void g_value_set_string_list (GValue *value, GList *list) { - GValueArray *value_array; - GValue element = G_VALUE_INIT; + GPtrArray *array; - g_value_init (&element, G_TYPE_STRING); - - value_array = g_value_array_new (g_list_length (list)); + array = g_ptr_array_new_full (g_list_length (list), g_free); while (list != NULL) { - g_value_set_string (&element, list->data); - g_value_array_append (value_array, &element); + g_ptr_array_add (array, g_strdup (list->data)); + list = list->next; } - g_value_take_boxed (value, value_array); + g_value_take_boxed (value, array); } static GList * g_value_dup_string_list (const GValue *value) { - GValueArray *value_array; + GPtrArray *array; GList *list = NULL; - GValue *element; gint ii; - value_array = g_value_get_boxed (value); + array = g_value_get_boxed (value); - for (ii = 0; ii < value_array->n_values; ii++) { - element = g_value_array_get_nth (value_array, ii); - list = g_list_prepend (list, g_value_dup_string (element)); + for (ii = 0; ii < array->len; ii++) { + const gchar *element = g_ptr_array_index (array, ii); + list = g_list_prepend (list, g_strdup (element)); } return g_list_reverse (list); @@ -963,7 +955,6 @@ static void e_composer_header_table_class_init (EComposerHeaderTableClass *class) { GObjectClass *object_class; - GParamSpec *element_spec; g_type_class_add_private (class, sizeof (EComposerHeaderTablePrivate)); @@ -973,45 +964,36 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class) object_class->dispose = composer_header_table_dispose; object_class->constructed = composer_header_table_constructed; - /* floating reference */ - element_spec = g_param_spec_object ( - "value-array-element", - NULL, - NULL, - E_TYPE_DESTINATION, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property ( object_class, PROP_DESTINATIONS_BCC, - g_param_spec_value_array ( + g_param_spec_boxed ( "destinations-bcc", NULL, NULL, - element_spec, + G_TYPE_PTR_ARRAY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property ( object_class, PROP_DESTINATIONS_CC, - g_param_spec_value_array ( + g_param_spec_boxed ( "destinations-cc", NULL, NULL, - element_spec, + G_TYPE_PTR_ARRAY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property ( object_class, PROP_DESTINATIONS_TO, - g_param_spec_value_array ( + g_param_spec_boxed ( "destinations-to", NULL, NULL, - element_spec, + G_TYPE_PTR_ARRAY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); @@ -1026,23 +1008,14 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - /* floating reference */ - element_spec = g_param_spec_string ( - "value-array-element", - NULL, - NULL, - NULL, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property ( object_class, PROP_POST_TO, - g_param_spec_value_array ( + g_param_spec_boxed ( "post-to", NULL, NULL, - element_spec, + G_TYPE_PTR_ARRAY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); diff --git a/em-format/e-mail-parser.c b/em-format/e-mail-parser.c index c718f79425..69d74af623 100644 --- a/em-format/e-mail-parser.c +++ b/em-format/e-mail-parser.c @@ -37,7 +37,7 @@ static gpointer parent_class = 0; struct _EMailParserPrivate { - GMutex *mutex; + GMutex mutex; gint last_error; @@ -176,10 +176,7 @@ e_mail_parser_finalize (GObject *object) priv = E_MAIL_PARSER (object)->priv; - if (priv->mutex) { - g_mutex_free (priv->mutex); - priv->mutex = NULL; - } + g_mutex_clear (&priv->mutex); G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -188,7 +185,7 @@ e_mail_parser_init (EMailParser *parser) { parser->priv = E_MAIL_PARSER_GET_PRIVATE (parser); - parser->priv->mutex = g_mutex_new (); + g_mutex_init (&parser->priv->mutex); } static void @@ -529,10 +526,10 @@ e_mail_parser_error (EMailParser *parser, g_free (errmsg); va_end (ap); - g_mutex_lock (parser->priv->mutex); + g_mutex_lock (&parser->priv->mutex); parser->priv->last_error++; uri = g_strdup_printf (".error.%d", parser->priv->last_error); - g_mutex_unlock (parser->priv->mutex); + g_mutex_unlock (&parser->priv->mutex); mail_part = e_mail_part_new (part, uri); mail_part->mime_type = g_strdup ("application/vnd.evolution.error"); diff --git a/libemail-engine/e-mail-session.c b/libemail-engine/e-mail-session.c index 63d5792965..aa3adefd12 100644 --- a/libemail-engine/e-mail-session.c +++ b/libemail-engine/e-mail-session.c @@ -90,7 +90,7 @@ struct _EMailSessionPrivate { GPtrArray *local_folder_uris; guint preparing_flush; - GMutex *preparing_flush_lock; + GMutex preparing_flush_lock; }; struct _AsyncContext { @@ -275,9 +275,9 @@ session_forward_to_flush_outbox_cb (gpointer user_data) { EMailSession *session = E_MAIL_SESSION (user_data); - g_mutex_lock (session->priv->preparing_flush_lock); - session->priv->preparing_flush_lock = 0; - g_mutex_unlock (session->priv->preparing_flush_lock); + g_mutex_lock (&session->priv->preparing_flush_lock); + session->priv->preparing_flush = 0; + g_mutex_unlock (&session->priv->preparing_flush_lock); /* Connect to this and call mail_send in the main email client.*/ g_signal_emit (session, signals[FLUSH_OUTBOX], 0); @@ -1012,7 +1012,7 @@ mail_session_finalize (GObject *object) g_ptr_array_free (priv->local_folders, TRUE); g_ptr_array_free (priv->local_folder_uris, TRUE); - g_mutex_free (priv->preparing_flush_lock); + g_mutex_clear (&priv->preparing_flush_lock); g_free (mail_data_dir); g_free (mail_config_dir); @@ -1685,7 +1685,7 @@ mail_session_forward_to_sync (CamelSession *session, flush_outbox = g_settings_get_boolean (settings, "flush-outbox"); g_object_unref (settings); - g_mutex_lock (priv->preparing_flush_lock); + g_mutex_lock (&priv->preparing_flush_lock); if (priv->preparing_flush > 0) { g_source_remove (priv->preparing_flush); @@ -1710,7 +1710,7 @@ mail_session_forward_to_sync (CamelSession *session, g_source_unref (timeout_source); } - g_mutex_unlock (priv->preparing_flush_lock); + g_mutex_unlock (&priv->preparing_flush_lock); } camel_message_info_free (info); @@ -1915,7 +1915,7 @@ e_mail_session_init (EMailSession *session) g_ptr_array_new_with_free_func ( (GDestroyNotify) g_free); - session->priv->preparing_flush_lock = g_mutex_new (); + g_mutex_init (&session->priv->preparing_flush_lock); } EMailSession * diff --git a/libemail-engine/mail-folder-cache.c b/libemail-engine/mail-folder-cache.c index 5561bb65f9..4d82557467 100644 --- a/libemail-engine/mail-folder-cache.c +++ b/libemail-engine/mail-folder-cache.c @@ -67,7 +67,7 @@ struct _MailFolderCachePrivate { /* Store to storeinfo table, active stores */ GHashTable *stores; /* mutex to protect access to the stores hash */ - GStaticRecMutex stores_mutex; + GRecMutex stores_mutex; /* List of folder changes to be executed in gui thread */ GQueue updates; /* idle source id for flushing all pending updates */ @@ -228,9 +228,9 @@ flush_updates_idle_cb (MailFolderCache *cache) { struct _folder_update *up; - g_static_rec_mutex_lock (&cache->priv->stores_mutex); + g_rec_mutex_lock (&cache->priv->stores_mutex); while ((up = g_queue_pop_head (&cache->priv->updates)) != NULL) { - g_static_rec_mutex_unlock (&cache->priv->stores_mutex); + g_rec_mutex_unlock (&cache->priv->stores_mutex); if (up->remove) { if (up->delete) { @@ -287,10 +287,10 @@ flush_updates_idle_cb (MailFolderCache *cache) free_update (up); - g_static_rec_mutex_lock (&cache->priv->stores_mutex); + g_rec_mutex_lock (&cache->priv->stores_mutex); } cache->priv->update_id = 0; - g_static_rec_mutex_unlock (&cache->priv->stores_mutex); + g_rec_mutex_unlock (&cache->priv->stores_mutex); return FALSE; } @@ -490,14 +490,14 @@ folder_changed_cb (CamelFolder *folder, last_newmail_per_folder, folder, GINT_TO_POINTER (new_latest_received)); - g_static_rec_mutex_lock (&cache->priv->stores_mutex); + g_rec_mutex_lock (&cache->priv->stores_mutex); if (cache->priv->stores != NULL && (si = g_hash_table_lookup (cache->priv->stores, parent_store)) != NULL && (mfi = g_hash_table_lookup (si->folders, full_name)) != NULL && mfi->folder == folder) { update_1folder (cache, mfi, new, uid, sender, subject, NULL); } - g_static_rec_mutex_unlock (&cache->priv->stores_mutex); + g_rec_mutex_unlock (&cache->priv->stores_mutex); g_free (uid); g_free (sender); @@ -593,11 +593,11 @@ store_folder_subscribed_cb (CamelStore *store, { StoreInfo *si; - g_static_rec_mutex_lock (&cache->priv->stores_mutex); + g_rec_mutex_lock (&cache->priv->stores_mutex); si = g_hash_table_lookup (cache->priv->stores, store); if (si) setup_folder (cache, info, si); - g_static_rec_mutex_unlock (&cache->priv->stores_mutex); + g_rec_mutex_unlock (&cache->priv->stores_mutex); } static void @@ -627,7 +627,7 @@ store_folder_unsubscribed_cb (CamelStore *store, StoreInfo *si; struct _folder_info *mfi; - g_static_rec_mutex_lock (&cache->priv->stores_mutex); + g_rec_mutex_lock (&cache->priv->stores_mutex); si = g_hash_table_lookup (cache->priv->stores, store); if (si) { mfi = g_hash_table_lookup (si->folders, info->full_name); @@ -636,7 +636,7 @@ store_folder_unsubscribed_cb (CamelStore *store, g_hash_table_remove (si->folders, mfi->full_name); } } - g_static_rec_mutex_unlock (&cache->priv->stores_mutex); + g_rec_mutex_unlock (&cache->priv->stores_mutex); } static void @@ -754,7 +754,7 @@ store_folder_renamed_cb (CamelStore *store, { StoreInfo *si; - g_static_rec_mutex_lock (&cache->priv->stores_mutex); + g_rec_mutex_lock (&cache->priv->stores_mutex); si = g_hash_table_lookup (cache->priv->stores, store); if (si) { GPtrArray *folders = g_ptr_array_new (); @@ -774,7 +774,7 @@ store_folder_renamed_cb (CamelStore *store, g_ptr_array_free (folders, TRUE); } - g_static_rec_mutex_unlock (&cache->priv->stores_mutex); + g_rec_mutex_unlock (&cache->priv->stores_mutex); } static void @@ -835,7 +835,7 @@ update_folders (CamelStore *store, g_error_free (error); } - g_static_rec_mutex_lock (&ud->cache->priv->stores_mutex); + g_rec_mutex_lock (&ud->cache->priv->stores_mutex); si = g_hash_table_lookup (ud->cache->priv->stores, store); if (si && !g_cancellable_is_cancelled (ud->cancellable)) { /* The 'si' is still there, so we can remove ourselves from @@ -846,7 +846,7 @@ update_folders (CamelStore *store, if (fi != NULL) create_folders (ud->cache, fi, si); } - g_static_rec_mutex_unlock (&ud->cache->priv->stores_mutex); + g_rec_mutex_unlock (&ud->cache->priv->stores_mutex); /* Do some extra work for the first update. */ if (si != NULL && si->first_update) { @@ -945,11 +945,11 @@ ping_store (CamelStore *store) static gboolean ping_cb (MailFolderCache *cache) { - g_static_rec_mutex_lock (&cache->priv->stores_mutex); + g_rec_mutex_lock (&cache->priv->stores_mutex); g_hash_table_foreach (cache->priv->stores, (GHFunc) ping_store, NULL); - g_static_rec_mutex_unlock (&cache->priv->stores_mutex); + g_rec_mutex_unlock (&cache->priv->stores_mutex); return TRUE; } @@ -980,7 +980,7 @@ store_go_online_cb (CamelStore *store, { /* FIXME Not checking result for error. */ - g_static_rec_mutex_lock (&ud->cache->priv->stores_mutex); + g_rec_mutex_lock (&ud->cache->priv->stores_mutex); if (g_hash_table_lookup (ud->cache->priv->stores, store) != NULL && !g_cancellable_is_cancelled (ud->cancellable)) { @@ -1001,7 +1001,7 @@ store_go_online_cb (CamelStore *store, g_free (ud); } - g_static_rec_mutex_unlock (&ud->cache->priv->stores_mutex); + g_rec_mutex_unlock (&ud->cache->priv->stores_mutex); } static GList * @@ -1120,7 +1120,7 @@ mail_folder_cache_finalize (GObject *object) priv = MAIL_FOLDER_CACHE_GET_PRIVATE (object); g_hash_table_destroy (priv->stores); - g_static_rec_mutex_free (&priv->stores_mutex); + g_rec_mutex_clear (&priv->stores_mutex); if (priv->ping_id > 0) { g_source_remove (priv->ping_id); @@ -1172,7 +1172,7 @@ mail_folder_cache_folder_available (MailFolderCache *cache, provider = camel_service_get_provider (service); /* Reuse the stores mutex just because it's handy. */ - g_static_rec_mutex_lock (&cache->priv->stores_mutex); + g_rec_mutex_lock (&cache->priv->stores_mutex); folder_uri = e_mail_folder_uri_build (store, folder_name); @@ -1186,7 +1186,7 @@ mail_folder_cache_folder_available (MailFolderCache *cache, else g_free (folder_uri); - g_static_rec_mutex_unlock (&cache->priv->stores_mutex); + g_rec_mutex_unlock (&cache->priv->stores_mutex); } static void @@ -1220,7 +1220,7 @@ mail_folder_cache_folder_unavailable (MailFolderCache *cache, provider = camel_service_get_provider (service); /* Reuse the stores mutex just because it's handy. */ - g_static_rec_mutex_lock (&cache->priv->stores_mutex); + g_rec_mutex_lock (&cache->priv->stores_mutex); folder_uri = e_mail_folder_uri_build (store, folder_name); @@ -1237,7 +1237,7 @@ mail_folder_cache_folder_unavailable (MailFolderCache *cache, g_free (folder_uri); - g_static_rec_mutex_unlock (&cache->priv->stores_mutex); + g_rec_mutex_unlock (&cache->priv->stores_mutex); } static void @@ -1269,7 +1269,7 @@ mail_folder_cache_folder_deleted (MailFolderCache *cache, session = camel_service_get_session (service); /* Reuse the stores mutex just because it's handy. */ - g_static_rec_mutex_lock (&cache->priv->stores_mutex); + g_rec_mutex_lock (&cache->priv->stores_mutex); folder_uri = e_mail_folder_uri_build (store, folder_name); @@ -1289,7 +1289,7 @@ mail_folder_cache_folder_deleted (MailFolderCache *cache, g_free (folder_uri); - g_static_rec_mutex_unlock (&cache->priv->stores_mutex); + g_rec_mutex_unlock (&cache->priv->stores_mutex); } static void @@ -1450,7 +1450,7 @@ mail_folder_cache_init (MailFolderCache *cache) /* initialize values */ cache->priv->stores = g_hash_table_new (NULL, NULL); - g_static_rec_mutex_init (&cache->priv->stores_mutex); + g_rec_mutex_init (&cache->priv->stores_mutex); g_queue_init (&cache->priv->updates); cache->priv->count_sent = getenv ("EVOLUTION_COUNT_SENT") != NULL; @@ -1507,7 +1507,7 @@ mail_folder_cache_note_store (MailFolderCache *cache, session = camel_service_get_session (CAMEL_SERVICE (store)); - g_static_rec_mutex_lock (&cache->priv->stores_mutex); + g_rec_mutex_lock (&cache->priv->stores_mutex); si = g_hash_table_lookup (cache->priv->stores, store); if (si == NULL) { @@ -1561,7 +1561,7 @@ mail_folder_cache_note_store (MailFolderCache *cache, g_queue_push_tail (&si->folderinfo_updates, ud); - g_static_rec_mutex_unlock (&cache->priv->stores_mutex); + g_rec_mutex_unlock (&cache->priv->stores_mutex); /* there is potential for race here, but it is safe as we check * for the store anyway */ @@ -1612,18 +1612,18 @@ mail_folder_cache_note_folder (MailFolderCache *cache, full_name = camel_folder_get_full_name (folder); parent_store = camel_folder_get_parent_store (folder); - g_static_rec_mutex_lock (&cache->priv->stores_mutex); + g_rec_mutex_lock (&cache->priv->stores_mutex); if (cache->priv->stores == NULL || (si = g_hash_table_lookup (cache->priv->stores, parent_store)) == NULL || (mfi = g_hash_table_lookup (si->folders, full_name)) == NULL) { w (g_warning ("Noting folder before store initialised")); - g_static_rec_mutex_unlock (&cache->priv->stores_mutex); + g_rec_mutex_unlock (&cache->priv->stores_mutex); return; } /* dont do anything if we already have this */ if (mfi->folder == folder) { - g_static_rec_mutex_unlock (&cache->priv->stores_mutex); + g_rec_mutex_unlock (&cache->priv->stores_mutex); return; } @@ -1633,7 +1633,7 @@ mail_folder_cache_note_folder (MailFolderCache *cache, update_1folder (cache, mfi, 0, NULL, NULL, NULL, NULL); - g_static_rec_mutex_unlock (&cache->priv->stores_mutex); + g_rec_mutex_unlock (&cache->priv->stores_mutex); g_signal_connect ( folder, "changed", @@ -1658,7 +1658,7 @@ mail_folder_cache_get_folder_from_uri (MailFolderCache *cache, if (cache->priv->stores == NULL) return FALSE; - g_static_rec_mutex_lock (&cache->priv->stores_mutex); + g_rec_mutex_lock (&cache->priv->stores_mutex); g_hash_table_foreach ( cache->priv->stores, (GHFunc) storeinfo_find_folder_info, &fi); @@ -1668,7 +1668,7 @@ mail_folder_cache_get_folder_from_uri (MailFolderCache *cache, else *folderp = NULL; } - g_static_rec_mutex_unlock (&cache->priv->stores_mutex); + g_rec_mutex_unlock (&cache->priv->stores_mutex); return fi.fi != NULL; } @@ -1687,7 +1687,7 @@ mail_folder_cache_get_folder_info_flags (MailFolderCache *cache, folder_uri = e_mail_folder_uri_from_folder (folder); fi.folder_uri = folder_uri; - g_static_rec_mutex_lock (&cache->priv->stores_mutex); + g_rec_mutex_lock (&cache->priv->stores_mutex); g_hash_table_foreach ( cache->priv->stores, (GHFunc) storeinfo_find_folder_info, &fi); @@ -1697,7 +1697,7 @@ mail_folder_cache_get_folder_info_flags (MailFolderCache *cache, else *flags = 0; } - g_static_rec_mutex_unlock (&cache->priv->stores_mutex); + g_rec_mutex_unlock (&cache->priv->stores_mutex); g_free (folder_uri); @@ -1723,13 +1723,13 @@ mail_folder_cache_get_folder_has_children (MailFolderCache *cache, folder_uri = e_mail_folder_uri_from_folder (folder); fi.folder_uri = folder_uri; - g_static_rec_mutex_lock (&cache->priv->stores_mutex); + g_rec_mutex_lock (&cache->priv->stores_mutex); g_hash_table_foreach ( cache->priv->stores, (GHFunc) storeinfo_find_folder_info, &fi); if (found != NULL) *found = fi.fi != NULL; - g_static_rec_mutex_unlock (&cache->priv->stores_mutex); + g_rec_mutex_unlock (&cache->priv->stores_mutex); g_free (folder_uri); @@ -1746,14 +1746,14 @@ mail_folder_cache_get_local_folder_uris (MailFolderCache *self, g_return_if_fail (out_queue != NULL); /* Reuse the stores mutex just because it's handy. */ - g_static_rec_mutex_lock (&self->priv->stores_mutex); + g_rec_mutex_lock (&self->priv->stores_mutex); head = g_queue_peek_head_link (&self->priv->local_folder_uris); for (link = head; link != NULL; link = g_list_next (link)) g_queue_push_tail (out_queue, g_strdup (link->data)); - g_static_rec_mutex_unlock (&self->priv->stores_mutex); + g_rec_mutex_unlock (&self->priv->stores_mutex); } void @@ -1766,14 +1766,14 @@ mail_folder_cache_get_remote_folder_uris (MailFolderCache *self, g_return_if_fail (out_queue != NULL); /* Reuse the stores mutex just because it's handy. */ - g_static_rec_mutex_lock (&self->priv->stores_mutex); + g_rec_mutex_lock (&self->priv->stores_mutex); head = g_queue_peek_head_link (&self->priv->remote_folder_uris); for (link = head; link != NULL; link = g_list_next (link)) g_queue_push_tail (out_queue, g_strdup (link->data)); - g_static_rec_mutex_unlock (&self->priv->stores_mutex); + g_rec_mutex_unlock (&self->priv->stores_mutex); } void @@ -1788,7 +1788,7 @@ mail_folder_cache_service_removed (MailFolderCache *cache, if (cache->priv->stores == NULL) return; - g_static_rec_mutex_lock (&cache->priv->stores_mutex); + g_rec_mutex_lock (&cache->priv->stores_mutex); si = g_hash_table_lookup (cache->priv->stores, service); if (si != NULL) { @@ -1805,7 +1805,7 @@ mail_folder_cache_service_removed (MailFolderCache *cache, store_info_free (si); } - g_static_rec_mutex_unlock (&cache->priv->stores_mutex); + g_rec_mutex_unlock (&cache->priv->stores_mutex); } void diff --git a/libemail-utils/mail-mt.c b/libemail-utils/mail-mt.c index 24a83db747..d7ed6922de 100644 --- a/libemail-utils/mail-mt.c +++ b/libemail-utils/mail-mt.c @@ -41,8 +41,8 @@ static guint mail_msg_seq; /* sequence number of each message */ /* Table of active messages. Must hold mail_msg_lock to access. */ static GHashTable *mail_msg_active_table; -static GMutex *mail_msg_lock; -static GCond *mail_msg_cond; +static GMutex mail_msg_lock; +static GCond mail_msg_cond; static MailMsgCreateActivityFunc create_activity = NULL; static MailMsgSubmitActivityFunc submit_activity = NULL; @@ -102,7 +102,7 @@ mail_msg_new (MailMsgInfo *info) { MailMsg *msg; - g_mutex_lock (mail_msg_lock); + g_mutex_lock (&mail_msg_lock); msg = g_slice_alloc0 (info->size); msg->info = info; @@ -124,7 +124,7 @@ mail_msg_new (MailMsgInfo *info) d (printf ("New message %p\n", msg)); - g_mutex_unlock (mail_msg_lock); + g_mutex_unlock (&mail_msg_lock); return msg; } @@ -205,14 +205,14 @@ mail_msg_unref (gpointer msg) if (mail_msg->info->free) mail_msg->info->free (mail_msg); - g_mutex_lock (mail_msg_lock); + g_mutex_lock (&mail_msg_lock); g_hash_table_remove ( mail_msg_active_table, GINT_TO_POINTER (mail_msg->seq)); - g_cond_broadcast (mail_msg_cond); + g_cond_broadcast (&mail_msg_cond); - g_mutex_unlock (mail_msg_lock); + g_mutex_unlock (&mail_msg_lock); /* Destroy the message from an idle callback * so we know we're in the main loop thread. */ @@ -270,7 +270,7 @@ mail_msg_cancel (guint msgid) MailMsg *msg; GCancellable *cancellable = NULL; - g_mutex_lock (mail_msg_lock); + g_mutex_lock (&mail_msg_lock); msg = g_hash_table_lookup ( mail_msg_active_table, GINT_TO_POINTER (msgid)); @@ -285,7 +285,7 @@ mail_msg_cancel (guint msgid) g_object_ref (cancellable); } - g_mutex_unlock (mail_msg_lock); + g_mutex_unlock (&mail_msg_lock); if (cancellable != NULL) { g_cancellable_cancel (cancellable); @@ -298,9 +298,9 @@ mail_msg_active (void) { gboolean active; - g_mutex_lock (mail_msg_lock); + g_mutex_lock (&mail_msg_lock); active = g_hash_table_size (mail_msg_active_table) > 0; - g_mutex_unlock (mail_msg_lock); + g_mutex_unlock (&mail_msg_lock); return active; } @@ -315,7 +315,7 @@ mail_cancel_hook_add (GHookFunc func, { GHook *hook; - g_mutex_lock (mail_msg_lock); + g_mutex_lock (&mail_msg_lock); if (!cancel_hook_list.is_setup) g_hook_list_init (&cancel_hook_list, sizeof (GHook)); @@ -326,7 +326,7 @@ mail_cancel_hook_add (GHookFunc func, g_hook_append (&cancel_hook_list, hook); - g_mutex_unlock (mail_msg_lock); + g_mutex_unlock (&mail_msg_lock); return hook; } @@ -334,12 +334,12 @@ mail_cancel_hook_add (GHookFunc func, void mail_cancel_hook_remove (GHook *hook) { - g_mutex_lock (mail_msg_lock); + g_mutex_lock (&mail_msg_lock); g_return_if_fail (cancel_hook_list.is_setup); g_hook_destroy_link (&cancel_hook_list, hook); - g_mutex_unlock (mail_msg_lock); + g_mutex_unlock (&mail_msg_lock); } void @@ -347,12 +347,12 @@ mail_cancel_all (void) { camel_operation_cancel_all (); - g_mutex_lock (mail_msg_lock); + g_mutex_lock (&mail_msg_lock); if (cancel_hook_list.is_setup) g_hook_list_invoke (&cancel_hook_list, FALSE); - g_mutex_unlock (mail_msg_lock); + g_mutex_unlock (&mail_msg_lock); } static guint idle_source_id = 0; @@ -437,8 +437,8 @@ mail_msg_proxy (MailMsg *msg) void mail_msg_init (void) { - mail_msg_lock = g_mutex_new (); - mail_msg_cond = g_cond_new (); + g_mutex_init (&mail_msg_lock); + g_cond_init (&mail_msg_cond); main_loop_queue = g_async_queue_new (); msg_reply_queue = g_async_queue_new (); diff --git a/mail/e-mail-autoconfig.c b/mail/e-mail-autoconfig.c index 65d735394a..5fa0fe23a6 100644 --- a/mail/e-mail-autoconfig.c +++ b/mail/e-mail-autoconfig.c @@ -289,14 +289,16 @@ mail_autoconfig_resolve_authority (const gchar *domain, * So use a reference count on the thread closure and always * let the thread run to completion even if we're not around * any longer to pick up the result. */ - resolver_thread = g_thread_create ( + resolver_thread = g_thread_try_new (NULL, mail_autoconfig_resolver_thread, resolver_closure_ref (closure), - FALSE /* not joinable */, error); + error); if (resolver_thread == NULL) return FALSE; + g_thread_unref (resolver_thread); + if (G_IS_CANCELLABLE (cancellable)) cancel_id = g_cancellable_connect ( cancellable, diff --git a/mail/importers/elm-importer.c b/mail/importers/elm-importer.c index 5b555cb1c7..02d29f5394 100644 --- a/mail/importers/elm-importer.c +++ b/mail/importers/elm-importer.c @@ -51,7 +51,7 @@ struct _elm_import_msg { EImport *import; EImportTargetHome *target; - GMutex *status_lock; + GMutex status_lock; gchar *status_what; gint status_pc; gint status_timeout_id; @@ -228,7 +228,7 @@ elm_import_free (struct _elm_import_msg *m) g_object_unref (m->status); g_free (m->status_what); - g_mutex_free (m->status_lock); + g_mutex_clear (&m->status_lock); g_source_remove (m->status_timeout_id); m->status_timeout_id = 0; @@ -244,11 +244,11 @@ elm_status (CamelOperation *op, { struct _elm_import_msg *importer = data; - g_mutex_lock (importer->status_lock); + g_mutex_lock (&importer->status_lock); g_free (importer->status_what); importer->status_what = g_strdup (what); importer->status_pc = pc; - g_mutex_unlock (importer->status_lock); + g_mutex_unlock (&importer->status_lock); } static gboolean @@ -259,11 +259,11 @@ elm_status_timeout (gpointer data) gchar *what; if (importer->status_what) { - g_mutex_lock (importer->status_lock); + g_mutex_lock (&importer->status_lock); what = importer->status_what; importer->status_what = NULL; pc = importer->status_pc; - g_mutex_unlock (importer->status_lock); + g_mutex_unlock (&importer->status_lock); e_import_status ( importer->import, (EImportTarget *) @@ -294,7 +294,7 @@ mail_importer_elm_import (EImport *ei, g_object_ref (m->import); m->target = (EImportTargetHome *) target; m->status_timeout_id = g_timeout_add (100, elm_status_timeout, m); - m->status_lock = g_mutex_new (); + g_mutex_init (&m->status_lock); m->status = camel_operation_new (); g_signal_connect ( diff --git a/mail/importers/evolution-mbox-importer.c b/mail/importers/evolution-mbox-importer.c index a024729bc2..0f1e507f2c 100644 --- a/mail/importers/evolution-mbox-importer.c +++ b/mail/importers/evolution-mbox-importer.c @@ -59,7 +59,7 @@ typedef struct { EImport *import; EImportTarget *target; - GMutex *status_lock; + GMutex status_lock; gchar *status_what; gint status_pc; gint status_timeout_id; @@ -207,11 +207,11 @@ mbox_status (CamelOperation *op, { MboxImporter *importer = data; - g_mutex_lock (importer->status_lock); + g_mutex_lock (&importer->status_lock); g_free (importer->status_what); importer->status_what = g_strdup (what); importer->status_pc = pc; - g_mutex_unlock (importer->status_lock); + g_mutex_unlock (&importer->status_lock); } static gboolean @@ -222,11 +222,11 @@ mbox_status_timeout (gpointer data) gchar *what; if (importer->status_what) { - g_mutex_lock (importer->status_lock); + g_mutex_lock (&importer->status_lock); what = importer->status_what; importer->status_what = NULL; pc = importer->status_pc; - g_mutex_unlock (importer->status_lock); + g_mutex_unlock (&importer->status_lock); e_import_status ( importer->import, (EImportTarget *) @@ -244,7 +244,7 @@ mbox_import_done (gpointer data, g_source_remove (importer->status_timeout_id); g_free (importer->status_what); - g_mutex_free (importer->status_lock); + g_mutex_clear (&importer->status_lock); g_object_unref (importer->cancellable); e_import_complete (importer->import, importer->target); @@ -275,7 +275,7 @@ mbox_import (EImport *ei, g_datalist_set_data (&target->data, "mbox-data", importer); importer->import = ei; importer->target = target; - importer->status_lock = g_mutex_new (); + g_mutex_init (&importer->status_lock); importer->status_timeout_id = g_timeout_add (100, mbox_status_timeout, importer); importer->cancellable = camel_operation_new (); diff --git a/mail/importers/pine-importer.c b/mail/importers/pine-importer.c index 664a77bcba..c8904c4e0b 100644 --- a/mail/importers/pine-importer.c +++ b/mail/importers/pine-importer.c @@ -53,7 +53,7 @@ struct _pine_import_msg { EImport *import; EImportTarget *target; - GMutex *status_lock; + GMutex status_lock; gchar *status_what; gint status_pc; gint status_timeout_id; @@ -298,7 +298,7 @@ pine_import_free (struct _pine_import_msg *m) g_object_unref (m->cancellable); g_free (m->status_what); - g_mutex_free (m->status_lock); + g_mutex_clear (&m->status_lock); g_source_remove (m->status_timeout_id); m->status_timeout_id = 0; @@ -314,11 +314,11 @@ pine_status (CamelOperation *op, { struct _pine_import_msg *importer = data; - g_mutex_lock (importer->status_lock); + g_mutex_lock (&importer->status_lock); g_free (importer->status_what); importer->status_what = g_strdup (what); importer->status_pc = pc; - g_mutex_unlock (importer->status_lock); + g_mutex_unlock (&importer->status_lock); } static gboolean @@ -328,11 +328,11 @@ pine_status_timeout (struct _pine_import_msg *importer) gchar *what; if (importer->status_what) { - g_mutex_lock (importer->status_lock); + g_mutex_lock (&importer->status_lock); what = importer->status_what; importer->status_what = NULL; pc = importer->status_pc; - g_mutex_unlock (importer->status_lock); + g_mutex_unlock (&importer->status_lock); e_import_status ( importer->import, (EImportTarget *) @@ -364,7 +364,7 @@ mail_importer_pine_import (EImport *ei, m->target = target; m->status_timeout_id = g_timeout_add ( 100, (GSourceFunc) pine_status_timeout, m); - m->status_lock = g_mutex_new (); + g_mutex_init (&m->status_lock); m->cancellable = camel_operation_new (); g_signal_connect ( diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c index 3bbb8160a5..baeea6e10b 100644 --- a/mail/mail-send-recv.c +++ b/mail/mail-send-recv.c @@ -88,7 +88,7 @@ struct _send_data { CamelFolder *inbox; time_t inbox_update; - GMutex *lock; + GMutex lock; GHashTable *folders; GHashTable *active; /* send_info's by uri */ @@ -173,7 +173,7 @@ setup_send_data (EMailSession *session) if (send_data == NULL) { send_data = data = g_malloc0 (sizeof (*data)); - data->lock = g_mutex_new (); + g_mutex_init (&data->lock); data->folders = g_hash_table_new_full ( g_str_hash, g_str_equal, (GDestroyNotify) NULL, @@ -223,7 +223,7 @@ free_send_data (void) g_list_free (data->infos); g_hash_table_destroy (data->active); g_hash_table_destroy (data->folders); - g_mutex_free (data->lock); + g_mutex_clear (&data->lock); g_free (data); send_data = NULL; } @@ -937,9 +937,9 @@ receive_get_folder (CamelFilterDriver *d, struct _folder_info *oldinfo; gpointer oldkey, oldinfoptr; - g_mutex_lock (info->data->lock); + g_mutex_lock (&info->data->lock); oldinfo = g_hash_table_lookup (info->data->folders, uri); - g_mutex_unlock (info->data->lock); + g_mutex_unlock (&info->data->lock); if (oldinfo) { g_object_ref (oldinfo->folder); @@ -954,7 +954,7 @@ receive_get_folder (CamelFilterDriver *d, /* we recheck that the folder hasn't snuck in while we were loading it... */ /* and we assume the newer one is the same, but unref the old one anyway */ - g_mutex_lock (info->data->lock); + g_mutex_lock (&info->data->lock); if (g_hash_table_lookup_extended ( info->data->folders, uri, &oldkey, &oldinfoptr)) { @@ -970,7 +970,7 @@ receive_get_folder (CamelFilterDriver *d, g_object_ref (folder); - g_mutex_unlock (info->data->lock); + g_mutex_unlock (&info->data->lock); return folder; } diff --git a/mail/message-list.c b/mail/message-list.c index da0be14fea..959193a653 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -2578,7 +2578,7 @@ message_list_init (MessageList *message_list) message_list->cursor_uid = NULL; message_list->last_sel_single = FALSE; - message_list->regen_lock = g_mutex_new (); + g_mutex_init (&message_list->regen_lock); /* TODO: Should this only get the selection if we're realised? */ p = message_list->priv; @@ -2747,7 +2747,7 @@ message_list_finalize (GObject *object) g_free (message_list->frozen_search); g_free (message_list->cursor_uid); - g_mutex_free (message_list->regen_lock); + g_mutex_clear (&message_list->regen_lock); clear_selection (message_list, &priv->clipboard); @@ -4833,9 +4833,9 @@ regen_list_done (struct _regen_list_msg *m) } else build_flat (m->ml, m->summary, m->changes); - g_mutex_lock (m->ml->regen_lock); + g_mutex_lock (&m->ml->regen_lock); m->ml->regen = g_list_remove (m->ml->regen, m); - g_mutex_unlock (m->ml->regen_lock); + g_mutex_unlock (&m->ml->regen_lock); if (m->ml->regen == NULL && m->ml->pending_select_uid) { gchar *uid; @@ -4904,9 +4904,9 @@ regen_list_free (struct _regen_list_msg *m) camel_folder_change_info_free (m->changes); /* we have to poke this here as well since we might've been cancelled and regened wont get called */ - g_mutex_lock (m->ml->regen_lock); + g_mutex_lock (&m->ml->regen_lock); m->ml->regen = g_list_remove (m->ml->regen, m); - g_mutex_unlock (m->ml->regen_lock); + g_mutex_unlock (&m->ml->regen_lock); if (m->expand_state) xmlFreeDoc (m->expand_state); @@ -4925,9 +4925,9 @@ static MailMsgInfo regen_list_info = { static gboolean ml_regen_timeout (struct _regen_list_msg *m) { - g_mutex_lock (m->ml->regen_lock); + g_mutex_lock (&m->ml->regen_lock); m->ml->regen = g_list_prepend (m->ml->regen, m); - g_mutex_unlock (m->ml->regen_lock); + g_mutex_unlock (&m->ml->regen_lock); /* TODO: we should manage our own thread stuff, would make cancelling outstanding stuff easier */ mail_msg_fast_ordered_push (m); @@ -4944,7 +4944,7 @@ mail_regen_cancel (MessageList *ml) if (ml->regen) { GList *link; - g_mutex_lock (ml->regen_lock); + g_mutex_lock (&ml->regen_lock); for (link = ml->regen; link != NULL; link = link->next) { MailMsg *mm = link->data; @@ -4954,7 +4954,7 @@ mail_regen_cancel (MessageList *ml) g_cancellable_cancel (cancellable); } - g_mutex_unlock (ml->regen_lock); + g_mutex_unlock (&ml->regen_lock); } /* including unqueued ones */ diff --git a/mail/message-list.h b/mail/message-list.h index 44a312e667..9c93c46b05 100644 --- a/mail/message-list.h +++ b/mail/message-list.h @@ -148,7 +148,7 @@ struct _MessageList { /* list of outstanding regeneration requests */ GList *regen; - GMutex *regen_lock; /* when writing to the regen, guard with this lock too */ + GMutex regen_lock; /* when writing to the regen, guard with this lock too */ gchar *pending_select_uid; /* set if we were busy regnerating * while we had a select come in */ gboolean pending_select_fallback; diff --git a/modules/book-config-ldap/e-source-ldap.c b/modules/book-config-ldap/e-source-ldap.c index 18bb104498..42d8a08eab 100644 --- a/modules/book-config-ldap/e-source-ldap.c +++ b/modules/book-config-ldap/e-source-ldap.c @@ -25,7 +25,7 @@ ((obj), E_TYPE_SOURCE_LDAP, ESourceLDAPPrivate)) struct _ESourceLDAPPrivate { - GMutex *property_lock; + GMutex property_lock; gboolean can_browse; gchar *filter; guint limit; @@ -225,7 +225,7 @@ source_ldap_finalize (GObject *object) priv = E_SOURCE_LDAP_GET_PRIVATE (object); - g_mutex_free (priv->property_lock); + g_mutex_clear (&priv->property_lock); g_free (priv->filter); g_free (priv->root_dn); @@ -386,7 +386,7 @@ static void e_source_ldap_init (ESourceLDAP *extension) { extension->priv = E_SOURCE_LDAP_GET_PRIVATE (extension); - extension->priv->property_lock = g_mutex_new (); + g_mutex_init (&extension->priv->property_lock); } void @@ -509,12 +509,12 @@ e_source_ldap_dup_filter (ESourceLDAP *extension) g_return_val_if_fail (E_IS_SOURCE_LDAP (extension), NULL); - g_mutex_lock (extension->priv->property_lock); + g_mutex_lock (&extension->priv->property_lock); protected = e_source_ldap_get_filter (extension); duplicate = g_strdup (protected); - g_mutex_unlock (extension->priv->property_lock); + g_mutex_unlock (&extension->priv->property_lock); return duplicate; } @@ -533,7 +533,7 @@ e_source_ldap_set_filter (ESourceLDAP *extension, !g_str_has_prefix (filter, "(") && !g_str_has_suffix (filter, ")"); - g_mutex_lock (extension->priv->property_lock); + g_mutex_lock (&extension->priv->property_lock); if (needs_parens) new_filter = g_strdup_printf ("(%s)", filter); @@ -541,7 +541,7 @@ e_source_ldap_set_filter (ESourceLDAP *extension, new_filter = g_strdup (filter); if (g_strcmp0 (extension->priv->filter, new_filter) == 0) { - g_mutex_unlock (extension->priv->property_lock); + g_mutex_unlock (&extension->priv->property_lock); g_free (new_filter); return; } @@ -549,7 +549,7 @@ e_source_ldap_set_filter (ESourceLDAP *extension, g_free (extension->priv->filter); extension->priv->filter = new_filter; - g_mutex_unlock (extension->priv->property_lock); + g_mutex_unlock (&extension->priv->property_lock); g_object_notify (G_OBJECT (extension), "filter"); } @@ -592,12 +592,12 @@ e_source_ldap_dup_root_dn (ESourceLDAP *extension) g_return_val_if_fail (E_IS_SOURCE_LDAP (extension), NULL); - g_mutex_lock (extension->priv->property_lock); + g_mutex_lock (&extension->priv->property_lock); protected = e_source_ldap_get_root_dn (extension); duplicate = g_strdup (protected); - g_mutex_unlock (extension->priv->property_lock); + g_mutex_unlock (&extension->priv->property_lock); return duplicate; } @@ -608,17 +608,17 @@ e_source_ldap_set_root_dn (ESourceLDAP *extension, { g_return_if_fail (E_IS_SOURCE_LDAP (extension)); - g_mutex_lock (extension->priv->property_lock); + g_mutex_lock (&extension->priv->property_lock); if (g_strcmp0 (extension->priv->root_dn, root_dn) == 0) { - g_mutex_unlock (extension->priv->property_lock); + g_mutex_unlock (&extension->priv->property_lock); return; } g_free (extension->priv->root_dn); extension->priv->root_dn = e_util_strdup_strip (root_dn); - g_mutex_unlock (extension->priv->property_lock); + g_mutex_unlock (&extension->priv->property_lock); g_object_notify (G_OBJECT (extension), "root-dn"); } diff --git a/modules/cal-config-local/e-source-local.c b/modules/cal-config-local/e-source-local.c index 6877cf0d27..10b737a858 100644 --- a/modules/cal-config-local/e-source-local.c +++ b/modules/cal-config-local/e-source-local.c @@ -23,7 +23,7 @@ ((obj), E_TYPE_SOURCE_LOCAL, ESourceLocalPrivate)) struct _ESourceLocalPrivate { - GMutex *property_lock; + GMutex property_lock; GFile *custom_file; }; @@ -95,7 +95,7 @@ source_local_finalize (GObject *object) priv = E_SOURCE_LOCAL_GET_PRIVATE (object); - g_mutex_free (priv->property_lock); + g_mutex_clear (&priv->property_lock); /* Chain up to parent's finalize() method. */ G_OBJECT_CLASS (e_source_local_parent_class)->finalize (object); @@ -140,7 +140,7 @@ static void e_source_local_init (ESourceLocal *extension) { extension->priv = E_SOURCE_LOCAL_GET_PRIVATE (extension); - extension->priv->property_lock = g_mutex_new (); + g_mutex_init (&extension->priv->property_lock); } void @@ -168,12 +168,12 @@ e_source_local_dup_custom_file (ESourceLocal *extension) g_return_val_if_fail (E_IS_SOURCE_LOCAL (extension), NULL); - g_mutex_lock (extension->priv->property_lock); + g_mutex_lock (&extension->priv->property_lock); protected = e_source_local_get_custom_file (extension); duplicate = (protected != NULL) ? g_file_dup (protected) : NULL; - g_mutex_unlock (extension->priv->property_lock); + g_mutex_unlock (&extension->priv->property_lock); return duplicate; } @@ -189,14 +189,14 @@ e_source_local_set_custom_file (ESourceLocal *extension, g_object_ref (custom_file); } - g_mutex_lock (extension->priv->property_lock); + g_mutex_lock (&extension->priv->property_lock); if (extension->priv->custom_file != NULL) g_object_unref (extension->priv->custom_file); extension->priv->custom_file = custom_file; - g_mutex_unlock (extension->priv->property_lock); + g_mutex_unlock (&extension->priv->property_lock); g_object_notify (G_OBJECT (extension), "custom-file"); } diff --git a/modules/cal-config-weather/e-source-weather.c b/modules/cal-config-weather/e-source-weather.c index 3440224173..4ba306408a 100644 --- a/modules/cal-config-weather/e-source-weather.c +++ b/modules/cal-config-weather/e-source-weather.c @@ -23,7 +23,7 @@ ((obj), E_TYPE_SOURCE_WEATHER, ESourceWeatherPrivate)) struct _ESourceWeatherPrivate { - GMutex *property_lock; + GMutex property_lock; ESourceWeatherUnits units; gchar *location; }; @@ -96,7 +96,7 @@ source_weather_finalize (GObject *object) priv = E_SOURCE_WEATHER_GET_PRIVATE (object); - g_mutex_free (priv->property_lock); + g_mutex_clear (&priv->property_lock); g_free (priv->location); @@ -155,7 +155,7 @@ static void e_source_weather_init (ESourceWeather *extension) { extension->priv = E_SOURCE_WEATHER_GET_PRIVATE (extension); - extension->priv->property_lock = g_mutex_new (); + g_mutex_init (&extension->priv->property_lock); } void @@ -198,12 +198,12 @@ e_source_weather_dup_location (ESourceWeather *extension) g_return_val_if_fail (E_IS_SOURCE_WEATHER (extension), NULL); - g_mutex_lock (extension->priv->property_lock); + g_mutex_lock (&extension->priv->property_lock); protected = e_source_weather_get_location (extension); duplicate = g_strdup (protected); - g_mutex_unlock (extension->priv->property_lock); + g_mutex_unlock (&extension->priv->property_lock); return duplicate; } @@ -216,11 +216,11 @@ e_source_weather_set_location (ESourceWeather *extension, g_return_if_fail (E_IS_SOURCE_WEATHER (extension)); - g_mutex_lock (extension->priv->property_lock); + g_mutex_lock (&extension->priv->property_lock); new_location = e_util_strdup_strip (location); if (g_strcmp0 (extension->priv->location, new_location) == 0) { - g_mutex_unlock (extension->priv->property_lock); + g_mutex_unlock (&extension->priv->property_lock); g_free (new_location); return; } @@ -228,7 +228,7 @@ e_source_weather_set_location (ESourceWeather *extension, g_free (extension->priv->location); extension->priv->location = new_location; - g_mutex_unlock (extension->priv->property_lock); + g_mutex_unlock (&extension->priv->property_lock); g_object_notify (G_OBJECT (extension), "location"); } diff --git a/modules/spamassassin/evolution-spamassassin.c b/modules/spamassassin/evolution-spamassassin.c index 480fedccd4..6a8affab83 100644 --- a/modules/spamassassin/evolution-spamassassin.c +++ b/modules/spamassassin/evolution-spamassassin.c @@ -63,7 +63,7 @@ struct _ESpamAssassin { EMailJunkFilter parent; GOnce spamd_testing; - GMutex *socket_path_mutex; + GMutex socket_path_mutex; gchar *pid_file; gchar *socket_path; @@ -412,7 +412,7 @@ spam_assassin_test_spamd_running (ESpamAssassin *extension, gint ii = 0; GError *error = NULL; - g_mutex_lock (extension->socket_path_mutex); + g_mutex_lock (&extension->socket_path_mutex); argv[ii++] = SPAMC_COMMAND; argv[ii++] = "--no-safe-fallback"; @@ -432,7 +432,7 @@ spam_assassin_test_spamd_running (ESpamAssassin *extension, g_error_free (error); } - g_mutex_unlock (extension->socket_path_mutex); + g_mutex_unlock (&extension->socket_path_mutex); return (exit_code == 0); } @@ -444,12 +444,12 @@ spam_assassin_kill_our_own_daemon (ESpamAssassin *extension) gchar *contents = NULL; GError *error = NULL; - g_mutex_lock (extension->socket_path_mutex); + g_mutex_lock (&extension->socket_path_mutex); g_free (extension->socket_path); extension->socket_path = NULL; - g_mutex_unlock (extension->socket_path_mutex); + g_mutex_unlock (&extension->socket_path_mutex); if (extension->pid_file == NULL) return; @@ -493,7 +493,7 @@ spam_assassin_start_our_own_daemon (ESpamAssassin *extension) gint fd; GError *error = NULL; - g_mutex_lock (extension->socket_path_mutex); + g_mutex_lock (&extension->socket_path_mutex); /* Don't put the PID files in Evolution's tmp directory * (as defined in e-mktemp.c) because that gets cleaned @@ -588,7 +588,7 @@ exit: g_free (pid_file); g_free (socket_path); - g_mutex_unlock (extension->socket_path_mutex); + g_mutex_unlock (&extension->socket_path_mutex); return started; } @@ -725,7 +725,7 @@ spam_assassin_finalize (GObject *object) { ESpamAssassin *extension = E_SPAM_ASSASSIN (object); - g_mutex_free (extension->socket_path_mutex); + g_mutex_clear (&extension->socket_path_mutex); g_free (extension->pid_file); g_free (extension->socket_path); @@ -809,7 +809,7 @@ spam_assassin_classify (CamelJunkFilter *junk_filter, if (g_cancellable_set_error_if_cancelled (cancellable, error)) return FALSE; - g_mutex_lock (extension->socket_path_mutex); + g_mutex_lock (&extension->socket_path_mutex); if (extension->use_spamc) { g_assert (SPAMC_COMMAND != NULL); @@ -860,7 +860,7 @@ spam_assassin_classify (CamelJunkFilter *junk_filter, else g_warn_if_fail (error == NULL || *error != NULL); - g_mutex_unlock (extension->socket_path_mutex); + g_mutex_unlock (&extension->socket_path_mutex); return status; } @@ -1084,7 +1084,7 @@ e_spam_assassin_init (ESpamAssassin *extension) { GSettings *settings; - extension->socket_path_mutex = g_mutex_new (); + g_mutex_init (&extension->socket_path_mutex); settings = g_settings_new ("org.gnome.evolution.spamassassin"); diff --git a/plugins/bbdb/bbdb.c b/plugins/bbdb/bbdb.c index e0d3ca3e91..b06d168fed 100644 --- a/plugins/bbdb/bbdb.c +++ b/plugins/bbdb/bbdb.c @@ -192,12 +192,13 @@ bbdb_do_thread (const gchar *name, * care of that, thus just add it to the queue */ todo = g_slist_append (todo, td); } else { + GThread *thread; GError *error = NULL; EBookClient *client = bbdb_create_book_client (AUTOMATIC_CONTACTS_ADDRESSBOOK); /* list was empty, add item and create a thread */ todo = g_slist_append (todo, td); - g_thread_create (bbdb_do_in_thread, client, FALSE, &error); + thread = g_thread_try_new (NULL, bbdb_do_in_thread, client, &error); if (error) { g_warning ("%s: Creation of the thread failed with error: %s", G_STRFUNC, error->message); @@ -206,6 +207,8 @@ bbdb_do_thread (const gchar *name, G_UNLOCK (todo); bbdb_do_in_thread (client); G_LOCK (todo); + } else { + g_thread_unref (thread); } } G_UNLOCK (todo); diff --git a/plugins/bbdb/gaimbuddies.c b/plugins/bbdb/gaimbuddies.c index 99352787e9..b59e683c8e 100644 --- a/plugins/bbdb/gaimbuddies.c +++ b/plugins/bbdb/gaimbuddies.c @@ -307,6 +307,7 @@ void bbdb_sync_buddy_list (void) { GList *blist; + GThread *thread; GError *error = NULL; EBookClient *client = NULL; struct sync_thread_data *std; @@ -339,7 +340,7 @@ bbdb_sync_buddy_list (void) syncing = TRUE; - g_thread_create (bbdb_sync_buddy_list_in_thread, std, FALSE, &error); + thread = g_thread_try_new (NULL, bbdb_sync_buddy_list_in_thread, std, &error); if (error) { g_warning ( "%s: Creation of the thread failed with error: %s", @@ -349,6 +350,8 @@ bbdb_sync_buddy_list (void) G_UNLOCK (syncing); bbdb_sync_buddy_list_in_thread (std); G_LOCK (syncing); + } else { + g_thread_unref (thread); } G_UNLOCK (syncing); diff --git a/plugins/dbx-import/dbx-importer.c b/plugins/dbx-import/dbx-importer.c index 14799fb583..7f850ae631 100644 --- a/plugins/dbx-import/dbx-importer.c +++ b/plugins/dbx-import/dbx-importer.c @@ -105,7 +105,7 @@ typedef struct { EImport *import; EImportTarget *target; - GMutex *status_lock; + GMutex status_lock; gchar *status_what; gint status_pc; gint status_timeout_id; @@ -736,7 +736,7 @@ static void dbx_import_free (DbxImporter *m) { g_free (m->status_what); - g_mutex_free (m->status_lock); + g_mutex_clear (&m->status_lock); g_source_remove (m->status_timeout_id); m->status_timeout_id = 0; @@ -764,11 +764,11 @@ dbx_status_timeout (gpointer data) gchar *what; if (importer->status_what) { - g_mutex_lock (importer->status_lock); + g_mutex_lock (&importer->status_lock); what = importer->status_what; importer->status_what = NULL; pc = importer->status_pc; - g_mutex_unlock (importer->status_lock); + g_mutex_unlock (&importer->status_lock); e_import_status ( importer->target->import, @@ -786,11 +786,11 @@ dbx_status (CamelOperation *op, { DbxImporter *importer = data; - g_mutex_lock (importer->status_lock); + g_mutex_lock (&importer->status_lock); g_free (importer->status_what); importer->status_what = g_strdup (what); importer->status_pc = pc; - g_mutex_unlock (importer->status_lock); + g_mutex_unlock (&importer->status_lock); } /* Start the main import operation */ @@ -813,7 +813,7 @@ org_gnome_evolution_readdbx_import (EImport *ei, m->status_timeout_id = g_timeout_add (100, dbx_status_timeout, m); /*m->status_timeout_id = NULL;*/ - m->status_lock = g_mutex_new (); + g_mutex_init (&m->status_lock); m->cancellable = camel_operation_new (); g_signal_connect ( diff --git a/plugins/external-editor/external-editor.c b/plugins/external-editor/external-editor.c index cac0a63ed5..42cdb9f9ff 100644 --- a/plugins/external-editor/external-editor.c +++ b/plugins/external-editor/external-editor.c @@ -53,7 +53,6 @@ static void ee_editor_command_changed (GtkWidget *textbox); static void ee_editor_immediate_launch_changed (GtkWidget *checkbox); -static void async_external_editor (EMsgComposer *composer); static gboolean editor_running (void); static gboolean key_press_cb (GtkWidget *widget, GdkEventKey *event, @@ -249,9 +248,13 @@ numlines (const gchar *text, return lineno; } -void -async_external_editor (EMsgComposer *composer) +static gboolean external_editor_running = FALSE; +static GMutex external_editor_running_lock; + +static gpointer +external_editor_thread (gpointer user_data) { + EMsgComposer *composer = user_data; gchar *filename = NULL; gint status = 0; GSettings *settings; @@ -280,7 +283,8 @@ async_external_editor (EMsgComposer *composer) /* run_error_dialog also calls enable_composer */ g_idle_add ((GSourceFunc) run_error_dialog, data); - return; + + goto finished; } settings = g_settings_new ("org.gnome.evolution.plugin.external-editor"); @@ -339,7 +343,7 @@ async_external_editor (EMsgComposer *composer) g_free (filename); g_free (editor_cmd_line); g_free (editor_cmd); - return; + goto finished; } g_free (editor_cmd_line); g_free (editor_cmd); @@ -351,7 +355,7 @@ async_external_editor (EMsgComposer *composer) #endif d (printf ("\n\nsome problem here with external editor\n\n")); g_idle_add ((GSourceFunc) enable_composer, composer); - return; + goto finished; } else { gchar *buf; @@ -373,6 +377,13 @@ async_external_editor (EMsgComposer *composer) g_free (filename); } } + + finished: + g_mutex_lock (&external_editor_running_lock); + external_editor_running = FALSE; + g_mutex_unlock (&external_editor_running_lock); + + return NULL; } static void launch_editor (GtkAction *action, EMsgComposer *composer) @@ -386,8 +397,13 @@ static void launch_editor (GtkAction *action, EMsgComposer *composer) disable_composer (composer); - editor_thread = g_thread_create ( - (GThreadFunc) async_external_editor, composer, FALSE, NULL); + g_mutex_lock (&external_editor_running_lock); + external_editor_running = TRUE; + g_mutex_unlock (&external_editor_running_lock); + + editor_thread = g_thread_new ( + NULL, external_editor_thread, composer); + g_thread_unref (editor_thread); } static GtkActionEntry entries[] = { @@ -431,21 +447,14 @@ key_press_cb (GtkWidget *widget, return TRUE; } -static void -editor_running_thread_func (GThread *thread, - gpointer running) -{ - if (thread == editor_thread) - *(gboolean*)running = TRUE; -} - -/* Racy? */ static gboolean editor_running (void) { - gboolean running = FALSE; + gboolean running; - g_thread_foreach ((GFunc) editor_running_thread_func, &running); + g_mutex_lock (&external_editor_running_lock); + running = external_editor_running; + g_mutex_unlock (&external_editor_running_lock); return running; } diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c index 2992fc961f..36801ccb99 100644 --- a/plugins/mail-to-task/mail-to-task.c +++ b/plugins/mail-to-task/mail-to-task.c @@ -559,8 +559,8 @@ struct _manage_comp ECalClient *client; ECalComponent *comp; icalcomponent *stored_comp; /* the one in client already */ - GCond *cond; - GMutex *mutex; + GCond cond; + GMutex mutex; gint mails_count; gint mails_done; gchar *editor_title; @@ -576,10 +576,8 @@ free_manage_comp_struct (struct _manage_comp *mc) g_object_unref (mc->client); if (mc->stored_comp) icalcomponent_free (mc->stored_comp); - if (mc->mutex) - g_mutex_free (mc->mutex); - if (mc->cond) - g_cond_free (mc->cond); + g_mutex_clear (&mc->mutex); + g_cond_clear (&mc->cond); if (mc->editor_title) g_free (mc->editor_title); @@ -681,7 +679,7 @@ comp_editor_closed (CompEditor *editor, /* Signal the do_mail_to_event thread that editor was closed and editor * for next event can be displayed (if any) */ - g_cond_signal (mc->cond); + g_cond_signal (&mc->cond); } /* @@ -807,12 +805,12 @@ do_manage_comp_idle (struct _manage_comp *mc) g_object_unref (edit_comp); } else { g_warning ("Failed to create event editor: %s", error ? error->message : "Unknown error"); - g_cond_signal (mc->cond); + g_cond_signal (&mc->cond); } } else { /* User canceled editing already existing event, so treat it as if he just closed the editor window */ comp_editor_closed (NULL, FALSE, mc); - g_cond_signal (mc->cond); + g_cond_signal (&mc->cond); } if (error) { @@ -979,8 +977,8 @@ do_mail_to_event (AsyncData *data) mc = g_new0 (struct _manage_comp, 1); mc->client = g_object_ref (client); mc->comp = g_object_ref (comp); - mc->mutex = g_mutex_new (); - mc->cond = g_cond_new (); + g_mutex_init (&mc->mutex); + g_cond_init (&mc->cond); mc->mails_count = uids->len; mc->mails_done = i + 1; /* Current task */ mc->editor_title = NULL; @@ -990,9 +988,9 @@ do_mail_to_event (AsyncData *data) /* Wait for user to quit the editor created in previous iteration * before displaying next one */ gboolean can_continue; - g_mutex_lock (oldmc->mutex); - g_cond_wait (oldmc->cond, oldmc->mutex); - g_mutex_unlock (oldmc->mutex); + g_mutex_lock (&oldmc->mutex); + g_cond_wait (&oldmc->cond, &oldmc->mutex); + g_mutex_unlock (&oldmc->mutex); can_continue = oldmc->can_continue; free_manage_comp_struct (oldmc); oldmc = NULL; @@ -1015,9 +1013,9 @@ do_mail_to_event (AsyncData *data) /* Wait for the last editor and then clean up */ if (oldmc) { - g_mutex_lock (oldmc->mutex); - g_cond_wait (oldmc->cond, oldmc->mutex); - g_mutex_unlock (oldmc->mutex); + g_mutex_lock (&oldmc->mutex); + g_cond_wait (&oldmc->cond, &oldmc->mutex); + g_mutex_unlock (&oldmc->mutex); free_manage_comp_struct (oldmc); } } @@ -1220,10 +1218,12 @@ mail_to_event (ECalClientSourceType source_type, else data->selected_text = NULL; - thread = g_thread_create ((GThreadFunc) do_mail_to_event, data, FALSE, &error); + thread = g_thread_try_new (NULL, (GThreadFunc) do_mail_to_event, data, &error); if (!thread) { - g_warning (G_STRLOC ": %s", error->message); + g_warning (G_STRLOC ": %s", error ? error->message : "Unknown error"); g_error_free (error); + } else { + g_thread_unref (thread); } } diff --git a/plugins/pst-import/pst-importer.c b/plugins/pst-import/pst-importer.c index 205bfff333..958b374ebc 100644 --- a/plugins/pst-import/pst-importer.c +++ b/plugins/pst-import/pst-importer.c @@ -109,7 +109,7 @@ struct _PstImporter { EImportTarget *target; gint waiting_open; - GMutex *status_lock; + GMutex status_lock; gchar *status_what; gint status_pc; gint status_timeout_id; @@ -2098,7 +2098,7 @@ pst_import_free (PstImporter *m) g_object_unref (m->cancellable); g_free (m->status_what); - g_mutex_free (m->status_lock); + g_mutex_clear (&m->status_lock); g_source_remove (m->status_timeout_id); m->status_timeout_id = 0; @@ -2125,11 +2125,11 @@ pst_status_timeout (gpointer data) gchar *what; if (importer->status_what) { - g_mutex_lock (importer->status_lock); + g_mutex_lock (&importer->status_lock); what = importer->status_what; importer->status_what = NULL; pc = importer->status_pc; - g_mutex_unlock (importer->status_lock); + g_mutex_unlock (&importer->status_lock); e_import_status (importer->target->import, (EImportTarget *) importer->target, what, pc); } @@ -2145,11 +2145,11 @@ pst_status (CamelOperation *op, { PstImporter *importer = data; - g_mutex_lock (importer->status_lock); + g_mutex_lock (&importer->status_lock); g_free (importer->status_what); importer->status_what = g_strdup (what); importer->status_pc = pc; - g_mutex_unlock (importer->status_lock); + g_mutex_unlock (&importer->status_lock); } static void @@ -2175,7 +2175,7 @@ pst_import (EImport *ei, m->status_timeout_id = g_timeout_add (100, pst_status_timeout, m); /*m->status_timeout_id = NULL;*/ - m->status_lock = g_mutex_new (); + g_mutex_init (&m->status_lock); m->cancellable = camel_operation_new (); g_signal_connect ( diff --git a/plugins/publish-calendar/publish-calendar.c b/plugins/publish-calendar/publish-calendar.c index 4193ae50d4..ab3e36dd6d 100644 --- a/plugins/publish-calendar/publish-calendar.c +++ b/plugins/publish-calendar/publish-calendar.c @@ -182,10 +182,12 @@ publish_uri_async (EPublishUri *uri) GThread *thread = NULL; GError *error = NULL; - thread = g_thread_create ((GThreadFunc) publish_no_succ_info, uri, FALSE, &error); + thread = g_thread_try_new (NULL, (GThreadFunc) publish_no_succ_info, uri, &error); if (!thread) { - g_warning (G_STRLOC ": %s", error->message); + g_warning (G_STRLOC ": %s", error ? error->message : "Unknown error"); g_error_free (error); + } else { + g_thread_unref (thread); } } @@ -993,10 +995,12 @@ e_plugin_lib_enable (EPlugin *ep, uris = g_settings_get_strv (settings, PC_SETTINGS_URIS); g_object_unref (settings); - thread = g_thread_create ((GThreadFunc) publish_uris_set_timeout, uris, FALSE, &error); + thread = g_thread_try_new (NULL, (GThreadFunc) publish_uris_set_timeout, uris, &error); if (!thread) { - g_warning ("Could create thread to set timeout for publishing uris : %s", error->message); + g_warning ("Could create thread to set timeout for publishing uris : %s", error ? error->message : "Unknown error"); g_error_free (error); + } else { + g_thread_unref (thread); } } @@ -1096,12 +1100,14 @@ action_calendar_publish_cb (GtkAction *action, GThread *thread = NULL; GError *error = NULL; - thread = g_thread_create ((GThreadFunc) publish_urls, NULL, FALSE, &error); + thread = g_thread_try_new (NULL, (GThreadFunc) publish_urls, NULL, &error); if (!thread) { /* To Translators: This is shown to a user when creation of a new thread, * where the publishing should be done, fails. Basically, this shouldn't * ever happen, and if so, then something is really wrong. */ error_queue_add (g_strdup (_("Could not create publish thread.")), error); + } else { + g_thread_unref (thread); } } diff --git a/shell/e-convert-local-mail.c b/shell/e-convert-local-mail.c index 8a726f8a99..7e94ee7175 100644 --- a/shell/e-convert-local-mail.c +++ b/shell/e-convert-local-mail.c @@ -190,6 +190,7 @@ migrate_mbox_to_maildir (EShell *shell, const gchar *mbox_uid; gchar *path; struct MigrateStore ms; + GThread *thread; GError *error = NULL; registry = e_shell_get_registry (shell); @@ -255,12 +256,13 @@ migrate_mbox_to_maildir (EShell *shell, ms.session = session; ms.complete = FALSE; - g_thread_create ((GThreadFunc) migrate_stores, &ms, TRUE, NULL); + thread = g_thread_new (NULL, (GThreadFunc) migrate_stores, &ms); while (!ms.complete) g_main_context_iteration (NULL, TRUE); g_object_unref (mbox_service); g_object_unref (maildir_service); + g_thread_unref (thread); return TRUE; } diff --git a/shell/e-shell.c b/shell/e-shell.c index 3440df7bbf..2f7cdcc8b5 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -52,7 +52,6 @@ struct _EShellPrivate { GQueue alerts; EShellSettings *settings; ESourceRegistry *registry; - GActionGroup *action_group; GtkWidget *preferences_window; /* Shell Backends */ @@ -238,19 +237,18 @@ shell_action_quit_cb (GSimpleAction *action, static void shell_add_actions (GApplication *application) { - EShell *shell; - GSimpleActionGroup *action_group; + GActionMap *action_map; GSimpleAction *action; - /* Add actions that remote instances can invoke. */ + action_map = G_ACTION_MAP (application); - action_group = g_simple_action_group_new (); + /* Add actions that remote instances can invoke. */ action = g_simple_action_new ("new-window", G_VARIANT_TYPE_STRING); g_signal_connect ( action, "activate", G_CALLBACK (shell_action_new_window_cb), application); - g_simple_action_group_insert (action_group, G_ACTION (action)); + g_action_map_add_action (action_map, G_ACTION (action)); g_object_unref (action); action = g_simple_action_new ( @@ -258,21 +256,15 @@ shell_add_actions (GApplication *application) g_signal_connect ( action, "activate", G_CALLBACK (shell_action_handle_uris_cb), application); - g_simple_action_group_insert (action_group, G_ACTION (action)); + g_action_map_add_action (action_map, G_ACTION (action)); g_object_unref (action); action = g_simple_action_new ("quit", NULL); g_signal_connect ( action, "activate", G_CALLBACK (shell_action_quit_cb), application); - g_simple_action_group_insert (action_group, G_ACTION (action)); + g_action_map_add_action (action_map, G_ACTION (action)); g_object_unref (action); - - shell = E_SHELL (application); - shell->priv->action_group = G_ACTION_GROUP (action_group); - - g_application_set_action_group ( - application, shell->priv->action_group); } static void @@ -721,11 +713,6 @@ shell_dispose (GObject *object) priv->registry = NULL; } - if (priv->action_group != NULL) { - g_object_unref (priv->action_group); - priv->action_group = NULL; - } - if (priv->preferences_window != NULL) { g_object_unref (priv->preferences_window); priv->preferences_window = NULL; diff --git a/smime/lib/e-cert-trust.c b/smime/lib/e-cert-trust.c index a23e0a7083..e99c5c4047 100644 --- a/smime/lib/e-cert-trust.c +++ b/smime/lib/e-cert-trust.c @@ -127,7 +127,7 @@ e_cert_trust_set_ssl_trust (CERTCertTrust *trust, { trust->sslFlags = 0; if (peer || tPeer) - e_cert_trust_add_trust (&trust->sslFlags, CERTDB_VALID_PEER); + e_cert_trust_add_trust (&trust->sslFlags, CERTDB_TERMINAL_RECORD); if (tPeer) e_cert_trust_add_trust (&trust->sslFlags, CERTDB_TRUSTED); if (ca || tCA) @@ -154,7 +154,7 @@ e_cert_trust_set_email_trust (CERTCertTrust *trust, { trust->emailFlags = 0; if (peer || tPeer) - e_cert_trust_add_trust (&trust->emailFlags, CERTDB_VALID_PEER); + e_cert_trust_add_trust (&trust->emailFlags, CERTDB_TERMINAL_RECORD); if (tPeer) e_cert_trust_add_trust (&trust->emailFlags, CERTDB_TRUSTED); if (ca || tCA) @@ -183,7 +183,7 @@ e_cert_trust_set_objsign_trust (CERTCertTrust *trust, if (peer || tPeer) e_cert_trust_add_trust ( &trust->objectSigningFlags, - CERTDB_VALID_PEER); + CERTDB_TERMINAL_RECORD); if (tPeer) e_cert_trust_add_trust ( &trust->objectSigningFlags, @@ -361,15 +361,15 @@ e_cert_trust_has_peer (CERTCertTrust *trust, PRBool checkObjSign) { if (checkSSL && !e_cert_trust_has_trust ( - trust->sslFlags, CERTDB_VALID_PEER)) + trust->sslFlags, CERTDB_TERMINAL_RECORD)) return PR_FALSE; if (checkEmail && !e_cert_trust_has_trust ( - trust->emailFlags, CERTDB_VALID_PEER)) + trust->emailFlags, CERTDB_TERMINAL_RECORD)) return PR_FALSE; if (checkObjSign && !e_cert_trust_has_trust ( - trust->objectSigningFlags, CERTDB_VALID_PEER)) + trust->objectSigningFlags, CERTDB_TERMINAL_RECORD)) return PR_FALSE; return PR_TRUE; diff --git a/widgets/misc/e-attachment-bar.c b/widgets/misc/e-attachment-bar.c index ed9fb02105..2f57a7f339 100644 --- a/widgets/misc/e-attachment-bar.c +++ b/widgets/misc/e-attachment-bar.c @@ -93,7 +93,7 @@ attachment_bar_update_status (EAttachmentBar *bar) num_attachments = e_attachment_store_get_num_attachments (store); total_size = e_attachment_store_get_total_size (store); - display_size = g_format_size_for_display (total_size); + display_size = g_format_size (total_size); if (total_size > 0) markup = g_strdup_printf ( diff --git a/widgets/misc/e-attachment-paned.c b/widgets/misc/e-attachment-paned.c index 119c66e6f2..565d91c4de 100644 --- a/widgets/misc/e-attachment-paned.c +++ b/widgets/misc/e-attachment-paned.c @@ -168,7 +168,7 @@ attachment_paned_update_status (EAttachmentPaned *paned) num_attachments = e_attachment_store_get_num_attachments (store); total_size = e_attachment_store_get_total_size (store); - display_size = g_format_size_for_display (total_size); + display_size = g_format_size (total_size); if (total_size > 0) markup = g_strdup_printf ( diff --git a/widgets/misc/e-attachment-tree-view.c b/widgets/misc/e-attachment-tree-view.c index 9a03d54a28..b73751fbbd 100644 --- a/widgets/misc/e-attachment-tree-view.c +++ b/widgets/misc/e-attachment-tree-view.c @@ -138,7 +138,7 @@ attachment_tree_view_render_size (GtkTreeViewColumn *column, gtk_tree_model_get (model, iter, column_id, &size, -1); if (size > 0) - display_size = g_format_size_for_display ((goffset) size); + display_size = g_format_size ((goffset) size); g_object_set (renderer, "text", display_size, NULL); diff --git a/widgets/misc/e-attachment.c b/widgets/misc/e-attachment.c index 315b012b2d..7b245e8b0d 100644 --- a/widgets/misc/e-attachment.c +++ b/widgets/misc/e-attachment.c @@ -220,7 +220,7 @@ attachment_update_file_info_columns (EAttachment *attachment) size = g_file_info_get_size (file_info); content_desc = g_content_type_get_description (content_type); - display_size = g_format_size_for_display (size); + display_size = g_format_size (size); description = e_attachment_get_description (attachment); if (description == NULL || *description == '\0') diff --git a/widgets/misc/e-picture-gallery.c b/widgets/misc/e-picture-gallery.c index 372e70146c..dc455400b3 100644 --- a/widgets/misc/e-picture-gallery.c +++ b/widgets/misc/e-picture-gallery.c @@ -105,7 +105,7 @@ update_file_iter (GtkListStore *list_store, if (filename) { filesize = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_STANDARD_SIZE); if (filesize) { - gchar *tmp = g_format_size_for_display ((goffset) filesize); + gchar *tmp = g_format_size ((goffset) filesize); filename_text = g_strdup_printf ("%s (%s)", filename, tmp); g_free (tmp); } -- cgit v1.2.3