From 3f1cf05ba629523e439b5c997c28f07ba71681fb Mon Sep 17 00:00:00 2001 From: Jonathan Matthew Date: Sat, 21 Jul 2012 16:52:57 +1000 Subject: [PATCH] replace g_thread_create with g_thread_new --- lib/rb-file-helpers.c | 2 +- lib/rb-thread.c | 5 +---- plugins/audiocd/rb-audiocd-source.c | 3 +-- plugins/audiocd/sj-metadata-getter.c | 13 +------------ plugins/ipod/rb-ipod-db.c | 5 +++-- plugins/ipod/rb-ipod-source.c | 2 +- plugins/mtpdevice/rb-mtp-thread.c | 2 +- podcast/rb-podcast-add-dialog.c | 8 +------- podcast/rb-podcast-manager.c | 16 ++++++---------- rhythmdb/rhythmdb-monitor.c | 2 +- rhythmdb/rhythmdb.c | 2 +- shell/rb-playlist-manager.c | 2 +- shell/rb-shell-player.c | 2 +- 13 files changed, 20 insertions(+), 44 deletions(-) diff --git a/lib/rb-file-helpers.c b/lib/rb-file-helpers.c index deaa64d20..f7924f1bc 100644 --- a/lib/rb-file-helpers.c +++ b/lib/rb-file-helpers.c @@ -964,7 +964,7 @@ rb_uri_handle_recursively_async (const char *uri, data->func = func; data->user_data = user_data; - g_thread_create ((GThreadFunc)_recurse_async_func, data, FALSE, NULL); + g_thread_new ("rb-uri-recurse", (GThreadFunc)_recurse_async_func, data); } /** diff --git a/lib/rb-thread.c b/lib/rb-thread.c index 2e41a8a35..856bdcdf8 100644 --- a/lib/rb-thread.c +++ b/lib/rb-thread.c @@ -280,16 +280,13 @@ rb_thread_constructor (GType type, guint n_construct_properties, RBThread *thread; RBThreadClass *klass; GObjectClass *parent_class; - GError *error = NULL; klass = RB_THREAD_CLASS (g_type_class_peek (RB_TYPE_THREAD)); parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass)); thread = RB_THREAD (parent_class->constructor (type, n_construct_properties, construct_properties)); - thread->priv->thread = g_thread_create (rb_thread_action_thread_main, thread, TRUE, &error); - if (!thread->priv->thread) - g_error ("Couldn't create thread: %s", error->message); + thread->priv->thread = g_thread_new ("rb-thread", rb_thread_action_thread_main, thread); /* Wait until the thread's mainloop is running */ g_mutex_lock (thread->priv->state_mutex); diff --git a/plugins/audiocd/rb-audiocd-source.c b/plugins/audiocd/rb-audiocd-source.c index 7b403a26b..66c3bc5f7 100644 --- a/plugins/audiocd/rb-audiocd-source.c +++ b/plugins/audiocd/rb-audiocd-source.c @@ -508,8 +508,7 @@ rb_audiocd_source_constructed (GObject *object) gtk_widget_show_all (grid); gtk_container_add (GTK_CONTAINER (source), grid); - g_thread_create ((GThreadFunc)rb_audiocd_load_songs, g_object_ref (source), FALSE, NULL); - + g_thread_new ("audiocd-scan", (GThreadFunc)rb_audiocd_load_songs, g_object_ref (source)); g_object_unref (db); g_object_unref (shell_player); } diff --git a/plugins/audiocd/sj-metadata-getter.c b/plugins/audiocd/sj-metadata-getter.c index cfc447d39..48c89a167 100644 --- a/plugins/audiocd/sj-metadata-getter.c +++ b/plugins/audiocd/sj-metadata-getter.c @@ -243,18 +243,7 @@ lookup_cd (SjMetadataGetter *mdg) gboolean sj_metadata_getter_list_albums (SjMetadataGetter *mdg, GError **error) { - GThread *thread; - - g_object_ref (mdg); - thread = g_thread_create ((GThreadFunc)lookup_cd, mdg, TRUE, error); - if (thread == NULL) { - g_set_error (error, - SJ_ERROR, SJ_ERROR_INTERNAL_ERROR, - _("Could not create CD lookup thread")); - g_object_unref (mdg); - return FALSE; - } - + g_thread_new ("sj-cd-lookup", (GThreadFunc)lookup_cd, g_object_ref (mdg)); return TRUE; } diff --git a/plugins/ipod/rb-ipod-db.c b/plugins/ipod/rb-ipod-db.c index 7015a9dd4..db90de229 100644 --- a/plugins/ipod/rb-ipod-db.c +++ b/plugins/ipod/rb-ipod-db.c @@ -886,8 +886,9 @@ save_timeout_cb (RbIpodDb *ipod_db) rb_debug ("Switching iPod database to read-only"); priv->read_only = TRUE; - priv->saving_thread = g_thread_create ((GThreadFunc)saving_thread, - ipod_db, TRUE, NULL); + priv->saving_thread = g_thread_new ("ipod-db-save", + (GThreadFunc)saving_thread, + ipod_db); priv->save_timeout_id = 0; return FALSE; } diff --git a/plugins/ipod/rb-ipod-source.c b/plugins/ipod/rb-ipod-source.c index 40bc7acc1..652ed83cc 100644 --- a/plugins/ipod/rb-ipod-source.c +++ b/plugins/ipod/rb-ipod-source.c @@ -1284,7 +1284,7 @@ impl_delete_entries (RBMediaPlayerSource *source, GList *entries, RBMediaPlayerS data->destroy_data = destroy_data; data->files = filenames; - g_thread_create ((GThreadFunc) delete_thread, data, FALSE, NULL); + g_thread_new ("ipod-delete", (GThreadFunc) delete_thread, data); } static RBTrackTransferBatch * diff --git a/plugins/mtpdevice/rb-mtp-thread.c b/plugins/mtpdevice/rb-mtp-thread.c index 23193b161..43ca0a60c 100644 --- a/plugins/mtpdevice/rb-mtp-thread.c +++ b/plugins/mtpdevice/rb-mtp-thread.c @@ -902,7 +902,7 @@ rb_mtp_thread_init (RBMtpThread *thread) thread->albums = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify) LIBMTP_destroy_album_t); - thread->thread = g_thread_create ((GThreadFunc) task_thread, thread, TRUE, NULL); /* XXX should handle errors i guess */ + thread->thread = g_thread_new ("mtp", (GThreadFunc) task_thread, thread); } static void diff --git a/podcast/rb-podcast-add-dialog.c b/podcast/rb-podcast-add-dialog.c index f4590e7f9..ec4e6d03c 100644 --- a/podcast/rb-podcast-add-dialog.c +++ b/podcast/rb-podcast-add-dialog.c @@ -361,7 +361,6 @@ static void parse_in_thread (RBPodcastAddDialog *dialog, const char *text, gboolean existing, gboolean single) { ParseThreadData *data; - GError *error = NULL; data = g_new0 (ParseThreadData, 1); data->dialog = g_object_ref (dialog); @@ -370,12 +369,7 @@ parse_in_thread (RBPodcastAddDialog *dialog, const char *text, gboolean existing data->existing = existing; data->single = single; - g_thread_create ((GThreadFunc) parse_thread, data, TRUE, &error); - if (error != NULL) { - /* ugh.. */ - g_warning ("Unable to create podcast parsing thread: %s", error->message); - g_clear_error (&error); - } + g_thread_new ("podcast parser", (GThreadFunc) parse_thread, data); } static void diff --git a/podcast/rb-podcast-manager.c b/podcast/rb-podcast-manager.c index 3d5068b1a..2a841de51 100644 --- a/podcast/rb-podcast-manager.c +++ b/podcast/rb-podcast-manager.c @@ -977,14 +977,9 @@ download_podcast (GFileInfo *src_info, RBPodcastManagerInfo *data) GDK_THREADS_LEAVE (); data->cancel = g_cancellable_new (); - data->thread = g_thread_create ((GThreadFunc) podcast_download_thread, - data, - TRUE, - &error); - if (error != NULL) { - download_error (data, error); - g_error_free (error); - } + data->thread = g_thread_new ("podcast-download", + (GThreadFunc) podcast_download_thread, + data); } static void @@ -1054,8 +1049,9 @@ rb_podcast_manager_subscribe_feed (RBPodcastManager *pd, const char *url, gboole info->automatic = automatic; info->existing_feed = existing_feed; - g_thread_create ((GThreadFunc) rb_podcast_manager_thread_parse_feed, - info, FALSE, NULL); + g_thread_new ("podcast-parse", + (GThreadFunc) rb_podcast_manager_thread_parse_feed, + info); return TRUE; } diff --git a/rhythmdb/rhythmdb-monitor.c b/rhythmdb/rhythmdb-monitor.c index 9a29917f8..7eed0a899 100644 --- a/rhythmdb/rhythmdb-monitor.c +++ b/rhythmdb/rhythmdb-monitor.c @@ -248,7 +248,7 @@ _monitor_entry_thread (RhythmDB *db) void rhythmdb_start_monitoring (RhythmDB *db) { - g_thread_create ((GThreadFunc)_monitor_entry_thread, g_object_ref (db), FALSE, NULL); + g_thread_new ("monitor-entry", (GThreadFunc)_monitor_entry_thread, g_object_ref (db)); /* monitor all library locations */ if (db->priv->library_locations) { diff --git a/rhythmdb/rhythmdb.c b/rhythmdb/rhythmdb.c index 9af8aa8e6..8526f1ccd 100644 --- a/rhythmdb/rhythmdb.c +++ b/rhythmdb/rhythmdb.c @@ -1192,7 +1192,7 @@ rhythmdb_thread_create (RhythmDB *db, if (pool) g_thread_pool_push (pool, data, NULL); else - g_thread_create ((GThreadFunc) func, data, FALSE, NULL); + g_thread_new ("rhythmdb-thread", (GThreadFunc) func, data); } static gboolean diff --git a/shell/rb-playlist-manager.c b/shell/rb-playlist-manager.c index 31ed95112..58434ac97 100644 --- a/shell/rb-playlist-manager.c +++ b/shell/rb-playlist-manager.c @@ -655,7 +655,7 @@ rb_playlist_manager_save_playlists (RBPlaylistManager *mgr, gboolean force) if (force) rb_playlist_manager_save_data (data); else - g_thread_create ((GThreadFunc) rb_playlist_manager_save_data, data, FALSE, NULL); + g_thread_new ("playlist-save", (GThreadFunc) rb_playlist_manager_save_data, data); return TRUE; } diff --git a/shell/rb-shell-player.c b/shell/rb-shell-player.c index e1dfe66b3..030b66253 100644 --- a/shell/rb-shell-player.c +++ b/shell/rb-shell-player.c @@ -1668,7 +1668,7 @@ rb_shell_player_open_location (RBShellPlayer *player, } data->cancellable = g_object_ref (player->priv->parser_cancellable); - g_thread_create ((GThreadFunc)open_location_thread, data, FALSE, NULL); + g_thread_new ("open-location", (GThreadFunc)open_location_thread, data); } else { if (player->priv->parser_cancellable != NULL) { g_object_unref (player->priv->parser_cancellable);